Oldschool CMD: deleting all files of a type with exceptions

Just some old school 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 specific name I want 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 ๐Ÿ˜€

2 thoughts on “Oldschool CMD: deleting all files of a type with exceptions

    1. 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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close