File Dates

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
snapper1969
Pro Scripter
Posts: 50
Joined: Fri Mar 23, 2007 10:14 am

File Dates

Post by snapper1969 » Mon Aug 25, 2008 3:00 pm

Hi,

I have the following script:

I'm trying to zip up the file wildcards that are created on the same day as the script is run. The script works fine except it zips up the filnames even if they have not been created that day, can anybody advise?.

Thx,

John

Dialog>MyDialog
Caption=GL Packaging
Left=300
Top=300
Width=305
Height=120
Label=Type Month / Week and Year:,5,5
Edit=MyEdit,5,22,230,For Example - 'Week 1 08' or 'Sept 08'
Button=Enter,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
//Use Memos for multiline edits
//Memo=MyEdit2,80,80,200,200,dd

EndDialog>MyDialog

Label>MainLoop
Show>MyDialog,result
If>result=2,end
If>result=3,Main
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>Main

ReadIniFile>c:\wg09.ini,mapping,sourcefiles,source
ReadIniFile>c:\wg09.ini,mapping,pcompleted,complete

Let>n=1
Label>business
ReadIniFile>c:\wg09.ini,archives,parm%n%,archive
If>archive=STOP,end
ReadIniFile>c:\wg09.ini,zipnames,parm%n%,zipname
If>zipname=STOP,end

Let>z=1
Label>files
ReadIniFile>c:\wg09.ini,%archive%,parm%z%,filename
If>filenamefiles

Day>the_day
Month>the_month
Year>the_year
Let>thisday=%the_year%%the_month%%the_day%
FileDate>%source%%filename%,fdate
if>fdate=thisday,zipfile,zipcounter
Label>zipfile
LibLoad>%SCRIPT_DIR%\Ziplib.dll,hZL
LibFunc>hZL,AddFiles,r,%complete%%zipname%,%source%%filename%,9,0
ZIP_Add>%complete%%zipname%,%source%%filename%,9,0,r
LibFree>hZL

Label>zipcounter
let>z=z+1
End>zipcounter
goto>files
End>zipfile

Label>counter
Let>n=n+1
End>counter
GoTo>business
Label>end

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Aug 25, 2008 3:10 pm

Use IfFileExists before doing ZIP_Add?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

snapper1969
Pro Scripter
Posts: 50
Joined: Fri Mar 23, 2007 10:14 am

Post by snapper1969 » Mon Aug 25, 2008 3:36 pm

mtettmar wrote:Use IfFileExists before doing ZIP_Add?
marcus, I put:
IfFileExists>%source%%filename%,,files

before the ZIP_Add but it is still adding old files to the zip.

I thought this would have been enough:

Day>the_day
Month>the_month
Year>the_year
Let>thisday=%the_year%%the_month%%the_day%
FileDate>%source%%filename%,fdate
if>fdate=thisday,zipfile,zipcounter

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Aug 25, 2008 3:40 pm

Code: Select all

I'm not sure if this works:

If>filename<STOP>files 

If>filename<>STOP,files

may be better 
Try stepping through it with the debugger (sorry Marcus :) )

snapper1969
Pro Scripter
Posts: 50
Joined: Fri Mar 23, 2007 10:14 am

Post by snapper1969 » Mon Aug 25, 2008 4:01 pm

I've changed the following but with no success:
Let>z=1
Label>files
ReadIniFile>c:\wg09.ini,%archive%,parm%z%,filename
If>filenamefiles

Day>the_day
Month>the_month
Year>the_year
Let>thisday=%the_year%%the_month%%the_day%
FileDate>%source%%filename%,fdate
if>fdate=thisday,zipfile,zipcounter
Label>zipfile
LibLoad>%SCRIPT_DIR%\Ziplib.dll,hZL
LibFunc>hZL,AddFiles,r,%complete%%zipname%,%source%%filename%,9,0
IfFileExists>%source%%filename%,,files
ZIP_Add>%complete%%zipname%,%source%%filename%,9,0,r
LibFree>hZL

Label>zipcounter
let>z=z+1
End>zipcounter
goto>files
End>zipfile

Label>counter
Let>n=n+1
End>counter
GoTo>business
Label>end

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Aug 25, 2008 4:02 pm

Do

Code: Select all

IfFileExists>%source%%filename%
  Zip_Add>%complete%%zipname%,%source%%filename%,9,0,r 
Endif
I.f. *IF* that file exists, add it to the zip file. Otherwise do nothing.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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