dimanche 7 janvier 2018

if EXIST "" reporting that unexisting folders exist

I've been on this code block for 10 minutes and can't manage to figure out why it report that folders that don't actually exist do exist. (%ALTCMD%) is set by the user, I've checked it and there is nothing wrong with that since the code reports correctly "Configuration %ALTCMD% was deleted." After some troubleshooting I've discovered that the line checks if "folder2" exists instead of %ALTCMD%, but if a folder inside "folder2" is actually there, it goes ahead and deletes that folder without touching "folder2".

SET ALTCMD=%CMD:~7%
    if NOT exist "%cd%\folder1\folder2\%ALTCDM%\" (
        set configexists=0
    ) ELSE (
        set configexists=1
    )
if "%configexists%"=="1" (
rmdir /s /q "%cd%\Folder1\Folder2\%ALTCMD%"
echo Confuguration "%ALTCMD%" was deleted.
pause>nul
goto configurationsmenu
) ELSE (
echo "%ALTCMD%" not Found.
pause>nul
goto configurationsmenu
)

Aucun commentaire:

Enregistrer un commentaire