Problems with Variable dates

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
isaaco
Newbie
Posts: 1
Joined: Wed Nov 17, 2004 4:02 am

Problems with Variable dates

Post by isaaco » Wed Nov 17, 2004 4:29 am

I make daily backups of all our data to a target folder using the current date as the filename. Here is the script. Works great.


Year>yy
Month>mm
Day>dd
Run Program>cmd /c XCopy S:\ d:\%MM%%DD%%YY% /s /e /h
Wait>2
Send Character/Text>D



The next macro burns it to DVD. So far so good. The problem is, I need to write a script to delete the backup folder that was created 8 days ago
on a daily basis to reclaim hard drive space. I wrote the following script, but it is not working properly. I got it working with let>dd=dd-6 it deletes the folder from 6 days ago. Also from the 1st to the 5 day of the month it does not work at all, probably because it has problems working with the new month. Any ideas? Thanks.


Year>yy
Month>mm
Day>dd
let>dd=dd-8
Change Directory>c:
Run Program>cmd /c rd /s /q c:\%MM%%DD%%YY%

Lumumba

Post by Lumumba » Wed Nov 17, 2004 7:50 am

I seem to remember that Add>; Sub> can be used to do date/time math.
GetDate>Today
Sub>Today, 6
MessageModal>%Today%
Have a try.
Untested.

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Wed Nov 17, 2004 7:35 pm

If Lumumba's suggestion doesn't work, you can use a tiny bit of VBScript the hard part foryou.
VBSTART
VBEND
VBEval>DateAdd("d",-8,date()),strOldDate
Message>%strOldDate%

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts