Oldschool CMD: deleting all files of a type with exceptions

Just some oldschool trickery: using the command prompt in windows (even works in dos! :) ) it’s very easy to delete all the files of a certain type except those having a specifc name I wan’t to keep. Imagine I need to recursively delete all the jpg files in a folder and subfolders, except those named “folder.jpg”. The following command does this:

del /s dir *.jpg  /s | find /i /v "folder.jpg"

Why I put this on my blog? Because I might need it for future reference :D

About these ads

About timdams
C#, .NET, Microsoft, security, .... Read more on : http://timdams.com/

2 Responses to Oldschool CMD: deleting all files of a type with exceptions

  1. en nu in powershell …

    • timdams says:

      Teach me mastah! (tbh powershell staat al lang op ‘to learn’ lijstje…maar dat lijstje is laaaaaang… :/ )

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 330 other followers

%d bloggers like this: