 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
scriptmonkey
Joined: 19 May 2006 Posts: 112
|
Posted: Mon May 12, 2008 7:59 pm Post subject: Script to move files older than 2 weeks into another folder |
|
|
I am trying to create a script that moves files AND folders over 2 weeks old into a "old" folder.
Before I started moving things, I am trying to get the day values correct. I am having trouble with the script.
| Code: |
MainDir = C:\DOWNLOADS\*.*
Loop,%MainDir%
{
var1= %A_Now%
FileGetTime,var2,%A_LoopFileName%,C
msgbox, todays date is %var1%
EnvSub, var1,%var2%,days
MsgBox, The file %A_LoopFileName% is %var1% days old
}
Return
|
_________________ Zak M. |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Mon May 12, 2008 10:43 pm Post subject: |
|
|
| Search the forum for backup AND file. |
|
| Back to top |
|
 |
poo_noo
Joined: 08 Dec 2006 Posts: 137 Location: Sydney Australia
|
Posted: Mon May 12, 2008 11:20 pm Post subject: |
|
|
Here is some code that I found & adapted from the forum
| Code: | ; Read the source directory for stat log files and move files greater than log_file_age days old
dir_source = %A_MyDocuments%\AutoHotkey\ahkstatsfile\*.log
dir_backup = \\%mybackupServer%
lastDate := A_Now
lastDate += -%log_file_age%, Days
Loop, %dir_source%
{
SplitPath A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
FileGetTime time, %A_LoopFileFullPath%
if (time <= lastDate)
FileMove %A_LoopFileFullPath%,%dir_backup%\%name%,1
FileDelete %A_LoopFileFullPath%,%dir_backup%\%name%
if ErrorLevel <0>
GoTo initialballoon
|
The log_file_age variable is defined in an .INI
edit : oopppps I reread the post.... this only does files and not directories _________________ Paul O |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|