I am facing an issue with my batch script doing a file deletion on Windows XP. The script has 2 roles: 1) Archive all the files in the given directory and moved to a different location. 2) delete the original files with 2 exceptions with a specific filename: evs and inspection.
This is the code:
Code: Select all
@ECHO OFF
setlocal EnableDelayedExpansion
SET TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%-%hr%%time:~3,2%%time:~6,2%%time:~9,2%
SET SrcDir=C:\Documents and Settings\Administrator\Desktop\BatchTest\Test
SET DestDir=C:\Documents and Settings\Administrator\Desktop\BatchTest\Archive-%TODAY%
IF NOT EXIST "%DestDir%" MD "%DestDir%"
ECHO.
FOR %%A IN ("%SrcDir%\*.*") DO "C:\Program Files\7-Zip\7z.exe" a -tzip "%DestDir%\%%~NXA.zip" "%%~A"
FOR %%A IN ("%SrcDir%\*.*") DO @set file=%%A && if !file!==!file:pack=! if !file!==!file:inspection=! (DEL /A !file!)
ECHO.
PAUSE
All I know is with an ECHO it will show the files that need to be deleted the full path.
My guess is it has to do something with Windows XP since its old, but I cannot find a solution for this.
Any help would be appreciated.