I'm creating a bat to remove all the .exe files from my desktop and downloads folder (which sometimes accumulate from so many downloads)...
call:delfiles "*.exe"
exit
:: funcion delfiles
@echo off
pause
goto:eof
:delfiles
set delfiles=%1
attrib -h -s -r +a "%USERPROFILE%\Downloads\%delfiles%"
attrib -h -s -r +a "%USERPROFILE%\Desktop\%delfiles%"
del /f /q "%USERPROFILE%\Downloads\%delfiles%"
del /f /q "%USERPROFILE%\Desktop\%delfiles%"
goto:eof
But I need to exclude a single "example.exe" located in these folders. How can I do it?
But I need to exclude one "example.exe" located in these folders. How can I do it?
you can occupy
Where %i is the name of each file it iterates and we compare it with the one you do NOT want to delete
EDIT
Now I got it to work in a .bat
You can try to hide that file and after deleting unhide it
Note: make a copy first just in case