copied from http://www.davewentzel.com/content/dba-box-scriptsThere are some changes I haven't gotten around to implementing in the last 10+ years. Someday...we delete files from the sqlbackups folder using DOS dir after constructing the date parameters in TSQL. This is wrong...if the agent wasn't running on a given day then those backups never get deleted. Proper way is to use FORFILES in DOS. This command *should* delete files where the file modified date property is older than 3 days.FORFILES /p d:\sqlbackups /s /m *.bak /d -3 /c "CMD/C del /Q /F @FILE"This needs to be tested.