AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deleting Files that are older than a specified time

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  

Was this Code Helpful?
yes
50%
 50%  [ 1 ]
no
50%
 50%  [ 1 ]
Total Votes : 2

Author Message
shaunsisk



Joined: 18 Jul 2006
Posts: 1
Location: Chicago

PostPosted: Tue Jul 18, 2006 7:21 pm    Post subject: Deleting Files that are older than a specified time Reply with quote

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
View user's profile Send private message Yahoo Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6789
Location: France (near Paris)

PostPosted: Wed Jul 19, 2006 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
polyethene



Joined: 11 Aug 2004
Posts: 5172
Location: /b/

PostPosted: Wed Jul 19, 2006 10:42 am    Post subject: Reply with quote

Well you can comment out the last line if you don't want them deleted permanently.
_________________
Chat (IRC)PlusNetScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group