Forfiles Utility

Leave a comment (0) Go to comments

To delete old database backup files get acquainted with the ForFiles utility. The Forfiles utility (forfiles.exe) comes installed with Windows Server 2003 and later. It enables batch processing of files. In conjunction with a SQL Server Agent job, you can use this utility to delete old database backup files to remove dependencies on items such as SQL Server maintenance plans, the xp_cmdshell extended stored procedure, or VBScript objects. For example, the following command uses Forfiles to delete all .bak files that are two days old or older in the F:\sql_backup folder:

forfiles /p “F:\sql_backup” /m “*.bak”

/c “cmd /c del /Q @path” /d -2

EOF - Forfiles Utility, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.