Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows CMD Search and Delete file by name

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?

like image 796
Ozzy Avatar asked May 14 '13 20:05

Ozzy


People also ask

How can I delete a file using cmd?

To delete a file, use the following command: del "<filename>" . For example, to delete Test file. txt , just run del "Test File. txt" .

How do I delete a file name in Windows?

Alternatively, head to the folder containing the files you want to delete, hit Shift + Right Click, and select Open a command window here. Then input "del [filename]" and press Enter.

What is rm command in Windows?

Use the rm command to remove files you no longer need. The rm command removes the entries for a specified file, group of files, or certain select files from a list within a directory.


1 Answers

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
like image 129
Magoo Avatar answered Sep 19 '22 12:09

Magoo