Make sure to run this as a test first to confirm the requirements are met.
E=mc2
ASKER
for /f "eol=: delims=" %F in ('findstr /m AB*123* *.txt') do del "%F"
The above does not work. I think it has to do with the fact that AB*123* is the string to look for, I don't think it's the correct syntax. If you look for *123* then it will work.
I need for the command to look for AB*123* within the file itself, and once it finds this string, then to delete the file that it found the string inside.
Steven Harris
OK, let's step back and look at it again...
Try running the following from directory where the files are. You should return all file names that meet the criteria:
for /F %a in ('dir /b *.txt findstr "AB*123*"') do @echo del "%a"
. Wildcard: any character
* Repeat: zero or more occurrences of previous character or class
^ Line position: beginning of line
$ Line position: end of line
Open in new window
If it is the "AB*123*" you are searching for in a txt file, then:
Open in new window
If you want to do this recursively, use /s:
Open in new window