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
Grawlix

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

DeleteFiles(sRoot)

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
			file.Delete(True)
		End If
	Next

	For Each folder in aSubFolders
		DeleteFiles(folder.Path)
	Next

End Function

Open in new window

AdrienneSperber

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
ASKER
Ricochet69

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
Grawlix

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
ASKER
Ricochet69

Thanks Guys,

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

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.
ASKER CERTIFIED SOLUTION
Ricochet69

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
or
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.