I have a batch file which searches through a directory tree deleting generated file backups.
I want to edit the script to run the del
command against the files found in the search, but I can't get it to work.
I've searched other threads and set it up similarly but without the expected results.
@echo off
pushd FILEPATH
echo Searching directories...
for /f "delims=" %%G in ('dir /b /s *.0**.rfa') do echo "%%G"
echo.
IF /I "%%G" == "" GOTO NOTFOUND
set /P delete="Delete files? [Y/N]: "
IF /I "%delete%" NEQ "Y" GOTO ENDOF
echo Deleting files...
echo.
del "%%G"
echo.
echo Done!
timeout 5
exit
:ENDOF
echo Aborted.
timeout 5
exit
:NOTFOUND
echo Found nothing.
timeout 5
exit
Result:
Deleting files... Could Not Find FILEPATH\ %G Done!