Avatar of Ricochet69
Ricochet69 asked on

Software that Automatically Deletes files older than X days

Can anyone recommend some good software that will delete files older than X days or that runs every month for shares on my server. If Microsoft had a tool that would be even better. Want to clear out some shares every month on our Server 2008.

Also looking some good quota management software for folders, i know Microsoft has management for drives but i need to apply it to a load of folders (users homes)

Thanks for any help.
Microsoft Server AppsMicrosoft Server OSWindows Server 2008

Avatar of undefined
Last Comment
Seth Simmons

8/22/2022 - Mon

You could use the following VBScript to accomplish this. You'll need to change the sRoot and NMaxFileAge variables to what you need and save it to .VBS. The create a task schedule job on the server with cscript.exe as the program and the path to the .vbs file as the arguments.

On Error Resume Next

Set oFileSys = WScript.CreateObject("Scripting.FileSystemObject")
sRoot = "C:\Path To Old Files"			'Path root to look for files
today = Date
nMaxFileAge = 3					'Files older than this (in days) will be deleted


Function DeleteFiles(ByVal sFolder)

	Set oFolder = oFileSys.GetFolder(sFolder)
	Set aFiles = oFolder.Files
	Set aSubFolders = oFolder.SubFolders

	For Each file in aFiles
		dFileCreated = FormatDateTime(file.DateCreated, "2")
		If DateDiff("d", dFileCreated, today) > nMaxFileAge Then
		End If

	For Each folder in aSubFolders

End Function

Open in new window


We create .bat files and then schedule them to run using windows task scheduler.
Here is a good reference for commands: http://ss64.com/nt/robocopy.html

Id like to get some nice and easy to use GUI software if anyone could recommend some without using scripts and windows scheduler.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

Here are a couple that will do what you are asking for in a gui.  Of course, the niceness of a programmed turnkey solution comes with a monetary cost.  ;)

File Automation Workshop

Win Quota

Thanks Guys,

Currently testing these out will get back when i come to a solution

I changed the vb script for just one day and i got the following error vbscript error
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Seth Simmons

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.