## move_on_date.tg
# So, how exactly do I move / delete a file at/over x-days-old?
#
{
-name move_on_date
# fire every second
-start -inc 0 0 0 1
# if there are no more files, break
-action -onerror no_more_files
# get the next file, if there are no more files
# we will stop here
-action -getfile -newest c:\file_store\*.* THE_FILE
# okay, check to see if the files age in days is greater than 15
# if so, move to the old_files folder, otherwise, move to the
# temp_folder.
# Files in the temp folder will be restored in the no_more_files procedure
-action -onerror temp_files
-action -test "%THE_FILE.AGE.DAYS% > 15"
-action -call old_files
}
## no_more_files
# Files in the temp_folder will be restored to their original location in this procedure
{
-name no_more_files
-action -print there are no more files. restoring from temp dir...
-command -hide CMD.EXE /c MOVE /Y "c:\file_store\temp_files\*.*" "c:\file_store"
-action -return break
}
## temp_files
# move 'NON-OLD' files to a temp folder
{
-name temp_files
-action -print temp_files
-action -move "%THE_FILE%" "c:\file_store\temp_files\%THE_FILE.FNAME%%THE_FILE.EXT%"
-action -return break
}
## old_files
# move 'OLD' files to a old_files folder
{
-name old_files
-action -print old_files
-action -move "%THE_FILE%" "c:\file_store\old_files\%THE_FILE.FNAME%%THE_FILE.EXT%"
-action -return break
}
_________________________
Regards,
Luke Tomasello