How to write command file to delete all files except two...

S

standish22

OK, to make the issue simple, I have a folder C:\Test

In it I have
Test1.txt
Test2.txt
Test3.txt
Test4.txt

I want to right a quick command that will delete all but Test2.txt and
Test4.txt. I've tried the following and can't get it to work:

DEL /s /[!Test2.txt] /[!Test4.txt] *.txt

DEL /s *.sql /EXCLUDE:Test2.txt /EXCLUDE:Test4.txt

EXCEPT (Test1.txt Test4.txt) (DEL /s *.txt)

None of these work.

Can anyone help?

Thanks....
 
N

NewScience

Possibly rename the files you want to save, delete what you don't want,
rename back to original?

OR

Does del test[13567890]*.txt work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top