Windows CMD Search and Delete file by name

Ozzy picture Ozzy · May 14, 2013 · Viewed 27.9k times · Source

I have a website dump which has about half a gig worth of images which have been converted to various file sizes. The structure goes like:

media/
   1/
      1.original.jpg
      1.large.jpg
      1.medium.jpg
      1.small.jpg
   2/
      2.original.jpg
      2.large.jpg
      2.medium.jpg
      2.small.jpg
etc...

I want a command that will search through all folders in media and delete any image which has original in the name. Is this possible?

Answer

Magoo picture Magoo · May 15, 2013
del /s ...\media\*original*.jpg

should delete all files with original in their name, extension .jpg from ...\media and all its subdirectories.

Obviously, use with extreme caution... If you desire to see what you are going to delete first before deleting it use

dir /s ...\media\*original*.jpg