Horatio Posted January 17, 2006 Share Posted January 17, 2006 I saw on the forum some tips how to use "autoIt" to zip files; my problem is: I need to zip every day multiple files and to give the right date (dd-mm-yyyy) at the zipped files, with different days of course. Greatings Horatio Link to comment Share on other sites More sharing options...
Valuater Posted January 17, 2006 Share Posted January 17, 2006 (edited) FirstWelcome to the Autoit ForumsSecondPlease post questions in the "Support" ForumThirdThis is the link to zip controlshttp://www.autoitscript.com/forum/index.ph...st=0&p=122806FourthYou can save file names with the macros below@SEC Seconds value of clock. Range is 00 to 59 @MIN Minutes value of clock. Range is 00 to 59 @HOUR Hours value of clock in 24-hour format. Range is 00 to 23 @MDAY Current day of month. Range is 01 to 31 @MON Current month. Range is 01 to 12 @YEAR Current four-digit year @WDAY Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. @YDAY Current day of year. Range is 1 to 366 (or 365 if not a leap year) 8) Edited January 17, 2006 by Valuater Link to comment Share on other sites More sharing options...
tonedeaf Posted January 17, 2006 Share Posted January 17, 2006 (edited) @Horatio Welcome to the forums If you want to set the date/time of Zip files, look up the following function in AutoIt help FileSetTime ( "file pattern", "time", type [, recurse] ) Edited January 17, 2006 by tonedeaf Link to comment Share on other sites More sharing options...
Gene Posted January 18, 2006 Share Posted January 18, 2006 I saw on the forum some tips how to use "autoIt" to zip files; my problem is: I need to zip every day multiple files and to give the right date (dd-mm-yyyy) at the zipped files, with different days of course. Greatings Horatio Horatio,A suggestion, file names incorporating the date in mm-dd-yyyy format, never sort in a logical order, but file names with the date in yyyy-mm-dd format, do sort in a logical order.Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Horatio Posted January 19, 2006 Author Share Posted January 19, 2006 Horatio,A suggestion, file names incorporating the date in mm-dd-yyyy format, never sort in a logical order, but file names with the date in yyyy-mm-dd format, do sort in a logical order.Gene Hello Gene,thanks for the council you can help to make the script I me nn I know the AutoIt program well.Bye Ps: I'm italian Link to comment Share on other sites More sharing options...
Gene Posted January 19, 2006 Share Posted January 19, 2006 Create the ".zip" file then rename it. In AutoIt the FileMove() function is used to rename files in place or to move them to a different folder and/or drive. Two possibilities for renaming the ".zip" file are below. $sNewFileName = FileMove ( "Path\OldFileName.zip", "Path\NewFileName" & @year & "-" & @Mon & "-" & @mday & ".zip" , 0 ) OR $sNewFileName = FileMove ( "Path\OldFileName.zip", "Path\NewFileName" & @year & "-" & @Mon & "-" & @mday & "-" & @hour & "-" & @min & "-" & @sec & ".zip" , 0 ) Search the forum for "zip", you should find some methods for creating ".zip" files using AutoIt. Try to code a script to do what you want. If you have trouble, come back to this thread, post the script you have at that point. Describe how it fails and/or what you don't understandand. Ask for more help, I or someone else will help you. This way you'll learn more, faster than if I or someone else just writes a script for you. I gave you the code snippets above because "FileMove" to rename a file is a little confusing. Gene Hello Gene, thanks for the council you can help to make the script I me nn I know the AutoIt program well. Bye Ps: I'm italian [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Horatio Posted January 19, 2006 Author Share Posted January 19, 2006 Thanks for the quick answer i make the scripts but when the programm i have this error send the scripts ... ---------------------------------------------------------------------------------------------------------------------------- $objZip = ObjCreate("XStandard.Zip") $objZip.Pack ("c:\try\*.*", "c:\try\zip\archive.zip") $objZip = "" $sNewFileName = FileMove ( "c:\try\zip\archive.zip", "H:\try\*.*" & @year & "-" & @Mon & "-" & @mday & ".zip" , 0 ) ----------------------------------------------------------------------------------------------------------------------------- Bye Horatio Create the ".zip" file then rename it. In AutoIt the FileMove() function is used to rename files in place or to move them to a different folder and/or drive. Two possibilities for renaming the ".zip" file are below. $sNewFileName = FileMove ( "Path\OldFileName.zip", "Path\NewFileName" & @year & "-" & @Mon & "-" & @mday & ".zip" , 0 ) OR $sNewFileName = FileMove ( "Path\OldFileName.zip", "Path\NewFileName" & @year & "-" & @Mon & "-" & @mday & "-" & @hour & "-" & @min & "-" & @sec & ".zip" , 0 ) Search the forum for "zip", you should find some methods for creating ".zip" files using AutoIt. Try to code a script to do what you want. If you have trouble, come back to this thread, post the script you have at that point. Describe how it fails and/or what you don't understandand. Ask for more help, I or someone else will help you. This way you'll learn more, faster than if I or someone else just writes a script for you. I gave you the code snippets above because "FileMove" to rename a file is a little confusing. Gene Link to comment Share on other sites More sharing options...
inthewayboy Posted February 2, 2006 Share Posted February 2, 2006 Just thought I would step in on this one, my first (And only?) post was about a similar issue. I ended up with something like this: Dim $qbooks $qbooks = @YEAR & "." & @MON & "." & @MDAY & ".7z" RunWait ( "7za.exe a -t7z -mx=9 " & $qbooks & "X:\TEMP\*.*" ) Now I'm not using the built-in zip support as you can see, but I find 7z has a much better compression ratio than a standard zip. Of course when I run this script I have the 7za.exe in my System32 dir...if you go with something like this then make sure you have the correct path to the exe that is compressing. The first line establishes a variable, $qbooks in this case. The second line defines the variable using the current date as the filename...if you'll notice how it's laid the whole file name in defined by the variable, including the extension. The final line runs the compression command. To make sure that the output is always the current date you insert the variable in where you would normally type the filename...depending on what compression scheme you use you'll have to adjust the syntax. Works without fail for me...and by using a better compression application you will most likely save bandwidth if you are transfering the files...but, with 7z at least, the higher the compression the harder the system has to work so keep that in mind! When the script runs it will take all files in the X:\TEMP folder and compresses them into on file...I like to have mine seperated by "." so the final outcome would be: 2006.02.02.7z If that were run today...you can change around the order if you like, but as someone already mentioned this structure is the most reliable when taking into account sorting methods. Link to comment Share on other sites More sharing options...
Gene Posted February 2, 2006 Share Posted February 2, 2006 The main thing, inthewayboy, is that your scripting idea can be adapted to any zip tool syntax, and it is simple. Gene Just thought I would step in on this one, my first (And only?) post was about a similar issue. I ended up with something like this: Dim $qbooks $qbooks = @YEAR & "." & @MON & "." & @MDAY & ".7z" RunWait ( "7za.exe a -t7z -mx=9 " & $qbooks & "X:\TEMP\*.*" ) Now I'm not using the built-in zip support as you can see, but I find 7z has a much better compression ratio than a standard zip. Of course when I run this script I have the 7za.exe in my System32 dir...if you go with something like this then make sure you have the correct path to the exe that is compressing. The first line establishes a variable, $qbooks in this case. The second line defines the variable using the current date as the filename...if you'll notice how it's laid the whole file name in defined by the variable, including the extension. The final line runs the compression command. To make sure that the output is always the current date you insert the variable in where you would normally type the filename...depending on what compression scheme you use you'll have to adjust the syntax. Works without fail for me...and by using a better compression application you will most likely save bandwidth if you are transfering the files...but, with 7z at least, the higher the compression the harder the system has to work so keep that in mind! When the script runs it will take all files in the X:\TEMP folder and compresses them into on file...I like to have mine seperated by "." so the final outcome would be: 2006.02.02.7z If that were run today...you can change around the order if you like, but as someone already mentioned this structure is the most reliable when taking into account sorting methods. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now