I want to create a Batch File that will delete a File that has any of the two names such as "new" or "1234" of any file format.
this is my file.txt:
new
1234
this is what I want to happen:
I already tried some of the codes I found online but It deleted some of my files. So I'm scared to re-run codes that has such WildCards hehe.
So far I have this:
SET FILENAME=DeleteLog.txt
SET USERLOG=%USERPROFILE%\%FILENAME%
rem I just declared the Downloads for safety-purposes but it should be C:\
SET TARGET1=%USERPROFILE%\Downloads
echo STARTING THE FILE DELETION >>%USERLOG%
cd %TARGET1%
rem file.txt contains the string (new,1234)
for /f "delims=" %%a in ("file.txt") do echo del %TARGET1%*%%a* >>%USERLOG%
echo FINISHING THE FILE DELETION >>%USERLOG%
My Logic is: For every file(new,1234).txt on my C:\ Drive -> Delete -> Log
I'm trying to follow this but it does not work for me: Batch file to delete files with relative name contained in text list? What seems to be the problem?
Any tips and suggestion will be appreciated :)