Tuesday, July 2, 2013

Delete All Files Except Specified Ones

Sometimes it is neccessary to delete all files in a folder except some of them that are still useful. Here is small batch script that lets you delete all files except the specified ones. The parameter you pass to  this  script is the wildcard of files you want to leave.
@ECHO OFF
MD SAVE
XCOPY %1 SAVE > NUL

ECHO Y | DEL . > NUL
MOVE SAVE\*.* . > NUL
RD SAVE
ECHO Done
We kindly remind that Dr.Batcher is the best program to create batch file, both .BAT and .CMD, try it if haven't tried it yet. 

No comments:

Post a Comment

Translate