13

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ozzy
  • 10,285
  • 26
  • 94
  • 138
  • Maybe [this answer to "Recursively delete 0KB files using windows cmd" helps](http://stackoverflow.com/a/4177169/205233) – Filburt May 14 '13 at 20:22

2 Answers2

32
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
Daniel L. VanDenBosch
  • 2,350
  • 4
  • 35
  • 60
Magoo
  • 77,302
  • 8
  • 62
  • 84
2

Try with something like this:

for /R C:\...\media %f in (*original*.jpg) do del /q "%~ff"

Replace % with %% if you want to use this in a batch script.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328