Hi
I'm about to do a script that will back up some files each day, but since I don't have to much space on the harddisk i want to delete some of the files again.
Everyday I got 2 new files uploaded to a root dir, I copy them to a dated folder, but I want to delete all files/folders older than 14 days except from mondays, sp my backup list will be like:
Mon 1 jan
Mon 8 jan
Mon 17 jan (14 days ago)
Tue 18 Jan
Wed 19 jan
.....
.....
.....
Hmm hope this make sense, i'm not sure.
Backup rotation
Moderators: JRL, Dorian (MJT support)
Hi,
Use GetFileList to get a list of files. See example in help file. Loop through each one. Use IfFileChanged command to see if file older than certain number of days. Use DeleteFile if so.
Or, use a sensible naming strategy like:
yyyymmdd.bak
That way, file name is easy to parse and determine age.
Use GetFileList to get a list of files. See example in help file. Loop through each one. Use IfFileChanged command to see if file older than certain number of days. Use DeleteFile if so.
Or, use a sensible naming strategy like:
yyyymmdd.bak
That way, file name is easy to parse and determine age.
MJT Net Support
[email protected]
[email protected]
If the naming format of your files will always be something like "Mon 8 Jan", then you can write a script that:
a) Obtains a list of filenames (see help file "GetFileList" example)
b) For each filename, gets the Day (Mon,etc), the date or month (Example: 8 ), and the month (Jan). If the day is Mon, then skip this filename.
c) Uses some code to see the number of days old. Here's a simple VBScript example I just made.
VBSTART
VBEND
Let>DayOfMonth=08
Let>Month=Jun
Let>Year=2003
Let>sOldDate=%Month%/%DayOfMonth%/%Year%
VBEval>DateDiff("d","%sOldDate%",Now),iAge
MessageModal>That date is %iAge% days old!(You might want to use a year in your filename, then things won't go boo boo when it gets to January)
Your script then deletes the file if the # of days is 14 or more.
If>%iAge%>14,LabelNameThatDeletes
(As I'm previewing this post, I see support has already answered. I'll post this anyway, cause perhaps you can use the VBScript routine)
[Edit: I adjusted the function to a simpler single VBEval line]
a) Obtains a list of filenames (see help file "GetFileList" example)
b) For each filename, gets the Day (Mon,etc), the date or month (Example: 8 ), and the month (Jan). If the day is Mon, then skip this filename.
c) Uses some code to see the number of days old. Here's a simple VBScript example I just made.

VBSTART
VBEND
Let>DayOfMonth=08
Let>Month=Jun
Let>Year=2003
Let>sOldDate=%Month%/%DayOfMonth%/%Year%
VBEval>DateDiff("d","%sOldDate%",Now),iAge
MessageModal>That date is %iAge% days old!(You might want to use a year in your filename, then things won't go boo boo when it gets to January)
Your script then deletes the file if the # of days is 14 or more.
If>%iAge%>14,LabelNameThatDeletes
(As I'm previewing this post, I see support has already answered. I'll post this anyway, cause perhaps you can use the VBScript routine)
[Edit: I adjusted the function to a simpler single VBEval line]