Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Deleting backup files older than 2 days

Author  Topic 

Starting Member

41 Posts

Posted - 2008-06-23 : 12:22:55
Friends -
I am looking for a windows script (bat file) to delete backup files which are older than 2 days.

Please provide scripts on this.

Appreciate your support

Cheers :)

Premature Yak Congratulator

22864 Posts

Posted - 2008-06-23 : 12:55:50
See if this helps

Also this is the forum to post workable scripts. If you want to ask questions you should post at relevent forums


Failing to plan is Planning to fail
Go to Top of Page

Starting Member

1 Post

Posted - 2008-07-09 : 23:08:31
FORFILES is a standard windows file that will do it for you = selects files and executes a command.
ForFiles /p "D:\Dumps" /m *.bak /D -2 /c "cmd /c del @path /Q"
This will look in the Dump directory for bak files that are older than 2 days and launch the del command to delete them.

Power corrupts, absolute power corrupts absolutely. But it rocks absolutely too.
Go to Top of Page

- Advertisement -