Click to See Complete Forum and Search --> : Selective DOS deleting


spuppett
September 27th, 2005, 11:39 AM
I have 190 files in a directory. What I want to do is delete all of them but about 20, then refill the directory with updated versions of the files I deleted. Or more specifly I want to delete the files that don't get overwritten after a copy. I don't really want to write out 170 deletes.

All the filenames that I want to save all start the same way.

IE del .\* except m2*.dbf

Anyone have anythoughts or ideas or am I stuck.

mmetzger
September 27th, 2005, 01:49 PM
You may have to do this in a couple steps and it depends on whether you can add some programs to help...

Using straight XP, you can do something like:


dir /b | findstr /r "^[^m][^2].*.[^d][^b][^f]"


It's not perfect, but should only list files not shown by your wildcard. You can then use scripting to delete it.

The other option is to simply write a quick piece of code in Perl, c#, etc that would take a directory and a true regex (or set of regex's) of what to delete.

spuppett
September 27th, 2005, 03:24 PM
thanks for the reply. I'm always hesitent to use reg expressions, cause I'm not too comfortable with them. But I'll look into it and maybe some perl.

PeejAvery
September 27th, 2005, 05:55 PM
A way around your problem...

md temp
move *.* temp
cd temp
move print*.* ..
cd..
del /q temp
rd temp

spuppett
September 28th, 2005, 08:27 AM
brillant.

PeejAvery
September 28th, 2005, 01:17 PM
brillant.
Thanks. I miss DOS.