jeudi 31 mai 2018

set command isn't working in if statement

For the life of me, I can't figure out why the below set prompt won't work when it is in the if statement:

@echo off

REM :askdeletecsvs
if exist *.csv (
    echo Warning! All files in the scripts folder that have the "CSV" extension will be deleted!
    echo Answering "n" will continue the script without deleting the CSVs.
    set /p ASKDELETE=Delete CSVs? (y/n): 
REM     
REM     if ( /i %ASKDELETE% equ "y" goto :deletecsvs )
REM     if ( /i %ASKDELETE% equ "n" goto :runscripts )
REM     goto :askdeletecsvs
)

When I run the batch file as it is above the cmd window opens and then shuts quickly. If I move the set line outside of the if statement then the prompt shows as expected.

What am I missing?

Aucun commentaire:

Enregistrer un commentaire