4
I have seen Deleting all files that do not match a certain pattern - Windows command line
However, I have not seen anything regarding how to delete everything that does not contain a certain string within its file name.
How can I delete all zip (other files should not be effected) files in a folder and its subfolders that don't have "MS" (case sensitive) in their file name.
These letters may be next to other letters (eg. a file names "ABCMSABC" should be kept because it has "MS" in it, but all other files should be deleted). Multiple files will have "MS" in them.
To at least point you in the right direction using the command line: You will probably need to use some combination of the "for" command (to loop through folders recursively), "dir", the "findstr" command with regular expressions (to weed out the files that don't contain "MS"), and then delete that result. – BrianC – 2016-03-16T02:44:44.097
@BrianC Regexp is not needed in the
findstr
– DavidPostill – 2016-03-16T09:46:03.767@DavidPostill true. I forgot about the /v option. – BrianC – 2016-03-16T13:18:34.050
@BrianC Never mind. You were correct. Regexp is required for a robust solution. – DavidPostill – 2016-03-16T19:14:36.917