I am trying to pull folder names from a database, and use this script to loop into those specific folders in a directory and delete certain file names that are stored in another txt file. For some reason it runs the SQL command but it skips everything and reaches the pause. I am trying to familiarize myself with the commands and syntax so it may just be a matter of another pair of eyes on it to see something out of whack.
The sql command creates the PicRemoverTemp.txt file just fine and the deletethese.txt just holds a couple .txt files that the script needs to loop through the folder names pulled from the DB and delete the files if they exist.
Thanks for the help!
@ECHO OFF
REM Creates "deletethese.txt" via sql command
FOR /F "tokens=1 delims=," %%G IN (PicRemoverTEMP.txt) DO (
SET "PathToCheck=P:\My Documents\Comm Trax Test\%%G"
FOR /F "tokens=1 delims=," %%v IN (deletethese.txt) DO (
REM Verify file exists before attempting to delete.
IF EXIST "%PathToCheck%\%%v" (
ECHO Deleting File %%v
DEL "%PathToCheck%\%%v"
)
)
)
PAUSE
CALL?