General discussion

Locked

Scripting Question

By rjackson ·
I'm tring to figureout a way to automaticaly delete old files. Files that are X number of days old. Any thoughts?

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Scripting Question

by nitemare In reply to Scripting Question

Hi,

I haven't seen a way to do this the way you mean, but you could:

1. Create a folder to store the data you want to delete.

2. Write a script to move the data to the folder.

3. Schedule a task in Scheduled Tasks/AT to delete all the contents of the folder every X days.

Regards,

Collapse -

Scripting Question

by rjackson In reply to Scripting Question

Poster rated this answer

Collapse -

Scripting Question

by Mark In reply to Scripting Question

This is easily done in a batch file, but you don't want to arbitrarily delete all files on your HD based on date. You could do this in your document or temp folder, but I fail to see why you have a need for this. Perhaps you should tell us about your problem instead of asking how to implement your solution. I'll take time to give you a batch file to do this once I hear a good reason.

Collapse -

Scripting Question

by rjackson In reply to Scripting Question

Poster rated this answer

Collapse -

Scripting Question

by rjackson In reply to Scripting Question

We have an FTP site that our customers use to load stuff to us. I need a way to cleanup this site. My thought was I could write a script that deletes files that are say 30 days old.

Collapse -

Scripting Question

by sritter In reply to Scripting Question

This is easily done with a vb script.
Here is some sample code.
Set wshShell = WScript.CreateObject("WScript.Shell")
Set fsObj = CreateObject("Scripting.FileSystemObject")

' Location of Folder that contains files
thisDir = "D:\test"

' Findall files in the directory
Set f = fsObj.GetFolder(thisDir)
Set fc = f.Files
For Each fl in fc
' If a file is older than 13 days kill it.
If (Now - fl.DateCreated) > 13 Then
fsObj.DeleteFile fl.name
End If
Next

Collapse -

Scripting Question

by rjackson In reply to Scripting Question

Thanks this seems to do the trick. The only negitive I can see is that you have to be in the directory that has the files you want to delete for it to run.

Collapse -

Scripting Question

by rjackson In reply to Scripting Question

This question was closed by the author

Back to Windows Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums