| View previous topic :: View next topic |
| Was this Code Helpful? |
| yes |
|
50% |
[ 1 ] |
| no |
|
50% |
[ 1 ] |
|
| Total Votes : 2 |
|
| Author |
Message |
shaunsisk
Joined: 18 Jul 2006 Posts: 1 Location: Chicago
|
Posted: Tue Jul 18, 2006 7:21 pm Post subject: Deleting Files that are older than a specified time |
|
|
This script allows for the deletion of files or folders that are older than a specific date and are of a specific file type or can be changed to delete all files in a folder. The script sends the files to the recycle bin and then empties the recycle bin to clear up disk space. GREAT FOR LOG FILES ON SERVERS!
| Code: |
;Check for the timestamp on the file prior to deletion
;Statements establish todays date and subtracts 7 days from it
;Places the date into the variable x.
x = %A_NowUTC%
x += -7, Days
;Successful Loop Statements
Time = %x%
OldFile =
Loop c:\source\*.dat* ; Loop the folder for specific files or all files
{
If (A_LoopFileTimeModified < Time)
{
OldFile := A_LoopFileLongPath
filerecycle, %OldFile%
}
}
;Empty the recely bin
fileRecycleEmpty
|
_________________ The only things in life you regret, are the chances you didn't take. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6789 Location: France (near Paris)
|
Posted: Wed Jul 19, 2006 8:42 am Post subject: |
|
|
I don't understand why you send files to the recycle bin to empty it just after.
Is this some trick? Otherwise, a simple FileDelete would have been enough. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
polyethene
Joined: 11 Aug 2004 Posts: 5172 Location: /b/
|
Posted: Wed Jul 19, 2006 10:42 am Post subject: |
|
|
Well you can comment out the last line if you don't want them deleted permanently. _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
|