[Batch] Problème de if goto
Bonjour à tous !
Quand j'exécute le code ci-dessous avec un argument et que je tape "y", il va toujours dans le ":CD" et jamais dans le ":MAKEDIR"... Est-ce que je fais une erreur quelquepart ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| IF "%1" == "" GOTO REMOVE
GOTO MOVE
:REMOVE
set /p conf="Are you sure that you want to delete all the old files from previous release, WITHOUT backup ? NO UNDO ! (y/n) Note : You can make a backup of these files by pressing "n" and executing this script with a directory argument."
if "%conf%" == "y" (
echo Deleting vieux.txt
del vieux.txt
echo The old files were removed !
)
GOTO FINISH
:MOVE
set /p conf2="Are you sure that you want to backup the old files in the %1 folder ? (y/n)"
if "%conf2%" == "y" GOTO MOVEOK
GOTO FINISH
:MOVEOK
CD %1 2>NUL IF ERRORLEVEL 1 GOTO MAKEDIR
GOTO CD
:MAKEDIR
md %1
GOTO MOVEFINAL
:CD
cd ..
:MOVEFINAL
echo Deleting vieux.txt
move vieux.txt %1\
echo The old files were moved into the %1 Directory !
:FINISH |
Merci d'avance !
Edit : Résolu ! Il faut faire un retour à la ligne ici :
Code:
1 2
| CD %1 2>NUL
IF ERRORLEVEL 1 GOTO MAKEDIR |