automatically remove files older than ‘x’ days

April 15, 2008

Tape backups have failed me too many times, so I now do my Windows backup to an external hard drive. One of the office staff is in charge of swapping out our backup drives and taking it offsite. I needed a solution that would remove old backups without user intervention so they wouldn’t have to worry about having enough space available for the backup to complete.My hard drives can hold four backups, so here’s a very simple .vbs script that deletes files from I:Backup Files that are more than three days old:

Dim Fso

Dim Directory

Dim Modified

Dim Files

Set Fso = CreateObject(”Scripting.FileSystemObject)

Set Directory = Fso.GetFolder(”I:Backup Files”)

Set Files = Directory.Files

For Each Modified in Files

If DateDiff(”D”, Modified.DateLastModified, Now) > 3 Then Modified.Delete


Save this as filename.vbs

To execute this file, run:

cscript.exe filename.vbs


You can read all about the 800a0408 error at http://www.computerperformance.co.uk/Logon/code/code_800A0408.htm

The quotation mark is not the correct ASCI character

Source: http://thebackroomtech.wordpress.com/2007/06/12/howto-automatically-remove-files-older-than-x-days/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: