Sign in to follow this  
Followers 0
Horatio

Help Me - Zip file and date of day

9 posts in this topic

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

:lmao:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

First

Welcome to the Autoit Forums

Second

Please post questions in the "Support" Forum

Third

This is the link to zip controls

http://www.autoitscript.com/forum/index.ph...st=0&p=122806

Fourth

You 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 by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by tonedeaf

Share this post


Link to post
Share on other sites

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

:lmao:

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...

Share this post


Link to post
Share on other sites

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 :lmao:

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 ;)

Share this post


Link to post
Share on other sites

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 :lmao:

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...

Share this post


Link to post
Share on other sites

Thanks for the quick answer i make the scripts but when the programm i have this error o:):lmao:

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 ;)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

The main thing, inthewayboy, is that your scripting idea can be adapted to any zip tool syntax, and it is simple. :lmao:

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...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0