How to delete files containing a specific line using a batch file in Windows?

My Panasonic camera uses its silly PHOTOfunSTUDIO to import photos. It creates folders by the name of the date when photos are taken, and imports the photos into these folders accordingly. So far, so good. But if I import again before deleting all the old pictures from the camera, the old ones will be imported again by adding the suffix of the name (002), (003), ..., no mater, as I changed the settings for this software.

My question is: how to delete all files with suffix names from these folders?

For example, this is one folder:

D:\Photos\2011\2011-12-01>dir /b 20111201_184550(002).cont 20111201_184550(002).iis 20111201_184550(002).m2ts 20111201_184550(002).tmb 20111201_184550.cont 20111201_184550.iis 20111201_184550.m2ts 20111201_184550.tmb 
+7
source share
3 answers

Well, maybe I was stupid. It does not need a package:

 del /s *(00?).* 
+8
source
 del *"("*")".* /s 

"" around (means that it is a character instead of being part of the delete command.
/ s - includes all subfolders

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/del.mspx?mfr=true

http://msdn.microsoft.com/en-us/library/ms690414%28v=vs.85%29.aspx

+2
source

you can easily use the asterix wildcard character (*) to search, just like any search utility

- search for the current folder if the directory is not specified

 del Search_Service_Application_1_*.trn 

- indication of the specific operation of the folder, even if you are on a different drive

 del d:\test\*copy*.txt 
+1
source

All Articles