Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

House Cleaning Script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to create a script that checks a directory for files that are older than a certain date and deletes them. To make things easier, the files are named the date that they were created. How can I do this?
 
Hi,

Dim objFSO, objParentFolder

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("C:\myFolder") then
Set objFolder = objFSO.GetFolder(("C:\myFolder")
Set objFolderContents = objFolder.Files

For Each objFileItem in objFolderContents

if objFileItem.lastmodifieddate < &quot;your required Date&quot; then
objFileItem.delete
Next

End If

Hope this helps..Even though syntax.little bit incorrect

All the Best
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top