General Question

clodoveo's avatar

Regular expressions in windows shell to delete multiple files, is it possible?

Asked by clodoveo (78points) August 8th, 2009

I have an image gallery in my pc with about 2000 pics or more, organized in hundreds of directories and sub-directories, recently my system got a virus that created several junk files in almost every folder, I was able to clean the virus but most of these files remained in the folders.

Basically, what I need to do, is to delete everything that isn’t a jpg file and every file that isn’t called gallery.xml.

Is it possible to do this using something like rm command with regular expressions but in the windows shell? I’m on vista.
I would appreciate if you guys can also help me with the necessary regular expression, I learned a bit of that years ago using linux but i’m a little rusty right now, Thank you! ;-)

Observing members: 0 Composing members: 0

2 Answers

MrItty's avatar

Windows’s cmd or command.com aren’t “real” shells in the Unix sense. I’d say you’re better off installing a scripting language like Perl (http://www.activeperl.com is the easiest Windows solution) and then run a simple one-liner:

perl -MFile::Find -e“find( sub{ unlink $_ if -f and !/\.jpe?g$/i and $_ ne q{gallery.xml} }, q{directory_to_search})”

Akiora's avatar

Ha…I was going to suggest something similar…beat me to it.

So…what he said.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther