Sign in to follow this  
Followers 0
skysel

Zip multiple files

3 posts in this topic

Hi again. I'm having a litte trouble figuring out, why my script isn't zipping files I've specified. If i'm checking what the script is doing, it does everything except zip the files. Where am I going wrong?

#Include <File.au3>
#Include <String.au3>
#Include <Array.au3>

;constants
Dim $filename = "aic01." & @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN
Dim $ext = ".zip"
Dim $newFilename = $filename & $ext
Dim $sharedFolder = "C:\Avayalogs"
Dim $Shell,$srcFolder,$DestFolder,$items;Objects
Dim $FileList = StringSplit("\\Ay-aic01\logs\ADU_Voice1.log,\\Ay-aic01\logs\Alarm.log,\\Ay-aic01\logs\DataServerMSSQL_Default.log,\\Ay-aic01\logs\DataServerMSSQL_Email.log,\\Ay-aic01\logs\DataServerMSSQL_Voice1.log,\\Ay-aic01\logs\DataServerMSSQL_Voice1_Helper.log,\\Ay-aic01\logs\EDU_Email_Helper.log,\\Ay-aic01\logs\EDU_Voice1_Helper.log,\\Ay-aic01\logs\Report_Email_Helper.log,\\Ay-aic01\logs\Report_Voice1_Helper.log,\\Ay-aic01\logs\TSDefinity_Voice1.log,\\Ay-aic01\logs\TSQS_Voice1.log,\\Ay-aic01\logs\VOX_Voice1.log,\\Ay-aic01\logs\WorkFlow_Email.log,\\Ay-aic01\logs\WorkFlow_User1.log,\\Ay-aic01\logs\WorkFlow_Voice1.log",",")



DirCreate("C:\def")
DirCreate("C:\zipout")
DirCreate("C:\Avayalogs")
$Destfolder = "C:\def\"
$zipout = "C:\zipout\" & $newFilename


for $n =1 to UBound($FileList) -1        
FileCopy($FileList[$n],$Destfolder)
Next
             
            

;compression part
$Shell = ObjCreate("Shell.Application")
InitZip($zipout)
$Shell.NameSpace($zipout).Copyhere ($destfolder,0)


;more compression
Func InitZip ($zip_path_name)
If NOT FileExists($zip_Path_name) then
      $init_zipString= Chr(80) & Chr(75) & Chr(5) & Chr(6)
        for $n =1 to 18                         
            $init_zipString= $init_zipString & Chr(0)    
        next
    $file =FileOpen($zip_path_name,18)                        
    FileWrite($file,$init_zipString)        
    FileClose($file)    
EndIf
EndFunc

;incremental file naming and copying
If FileExists($sharedFolder & "\" & $filename & $ext) Then
$num = 1
Do
$newFilename = $filename & "-" & $num & $ext
$num += 1
Until NOT FileExists($sharedFolder & "\" & $newFilename)
EndIf

FileCopy ("C:\zipout" & "\" & $filename & $ext, $sharedFolder & "\" & $newFilename)

;removing temporary files
FileDelete("C:\zipout" & "\" & $newFilename)
DirRemove("C:\zipout")
FileDelete("C:\def" & "\" & "*.log")
DirRemove("C:\def\")

Share this post


Link to post
Share on other sites



probably it depends on the file's sizes

go check my zip udf

or just add a loop at the end of the zipping function (for each file) telling the script to pause until the number of items isn't increased by 1

cheers!


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

Thanks alot, your UDF works as expected :mellow:

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