Windows CMD Search and delete a file by name

I have a website dump that has about half the cost of images that have been converted to various file sizes. The structure is as follows:

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 need a command that will search all folders on the media and delete any image with original in the name. Is it possible?

+6
source share
2 answers
 del /s ...\media\*original*.jpg 

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

Obviously, use with extreme caution ... If you want to see what you are about to remove before uninstalling, use

 dir /s ...\media\*original*.jpg 
+16
source

Try something like this:

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

Replace % with %% if you want to use it in a script package.

+1
source

Source: https://habr.com/ru/post/945008/


All Articles