Wednesday, March 2, 2011

Remove All Files Except Today's One with Help of Batch Files


Task to be discussed today is "How to remove all files from the specified folder except the file with today's name?". This is not a very common task, but it is useful for making different backup batch scripts. And this task is simple, as far as you can see. The code below shows how to delete all files in the current folder except the file which name contains today's date.
@echo off
attrib +r *%date%*
del /q *.* 1>nul 2>&1
attrib -r *%date%*
Hope you'll find this simple code useful.

No comments:

Post a Comment

Translate