I need a bat to delete all files with the RELATIVE name contained in a text file
In the files directory the files are named like:
1_a.jpg
1_b.jpg
1_c.jpg
2_a.jpg
3_a.jpg
3_b.jpg
In the file list to delete the RELATIVE name is
2
3
I want to delete all files contains 2 and 3 (specified in file list)
After deletion remain in my folder these files (bacause not contain 2 or 3)
1_a.jpg
1_b.jpg
1_c.jpg
I tryed a batch files but i need to reverse it because this bat do not remove the files specified in text list
@echo off
setlocal
set folder="c:\somePath"
set excludeFile="c:\somePath2\someFile.txt"
for /f "eol=: delims=" %%F in ('dir /b /a-d %folder% ^| findstr /vibg:%excludeFile%') do del "%folder%\%%F"
Can you help me please?
Here there are the code to reverse to delete the files only in text list.
Is it possible for a batch file to delete a file if not found in list from text file?