MiriamSapir Posted August 14, 2011 Posted August 14, 2011 Hi, I need to zip text and excel files. I've searched the forum and help file (which only specifices how to install winzip) but could not find what I needed. Another problem is that I'm not very technical, and the wealth of information threw me off. So please, be patient with my very basic, silly-sounding questions. Once a week, same files but newly created, with the same name, in the same path, need to be zipped using winzip. In the help forum, found this, but again - I don't really understand all the lines. I don't need a log file or a message box. Is the loop necessary? Hope I'm not being to basic here. Thanks for your patience. Miriam #include <Process.au3> $logfilepath=IniRead(@ScriptDir & "\Options.ini", "LOGPATH", "Logfilepath", @ScriptDir &'\zip.log') $filestozip=IniRead(@ScriptDir & "\Options.ini", "ZIPFILES", "FilesToZip", 0) _Zipfiles($filestozip) ; run function Func _Zipfiles($pathtozip) $a = FileGetShortName($pathtozip) $Zipto=IniRead(@ScriptDir & "\options.ini", "ZIPFILES", "WhereToZip","''") ;MsgBox(0,$a,$Pathtozip & ' in _zip func') $zipPath='"C:\Program files\WinZip\WZzip"' & ' -m ' & $Zipto & " " & $pathtozip & ' -ybc' MsgBox(0,"Test ZIPPING",$zipPath) _FileWriteLog($logfilepath,$zipPath) $rc = _RunDos($zipPath) Sleep(3000) If $rc >=1 Then _FileWriteLog($logfilepath, "Failed to zip " & " returned an error code of " & $rc) Else _FileWriteLog($logfilepath, "Success zipping " & ".zip returned an error code of " & $rc) Endif Endfunc
enaiman Posted August 14, 2011 Posted August 14, 2011 You don't need the log if you are not going to use it - it is useful and personally I don't see any reason to NOT use it. Only several lines in the script - won't hurt at all.If you don't want logging - just comment the lines.The message box is there just to show that the archiving will be done - just comment that and it will be fine.Is the loop necessary?Do you mean this?If $rc >=1 Then_FileWriteLog($logfilepath, "Failed to zip " & " returned an error code of " & $rc)Else_FileWriteLog($logfilepath, "Success zipping " & ".zip returned an error code of " & $rc)EndifIf you will use the log - it is necessary because it will write the appropriate message (success/fail)Once a week, same files but newly created, with the same name, in the same path, need to be zipped using winzipIf the file has the same name, same path - when you zip-it it will overwrite the old one - if you want that - then it's OK. If not - you will need to change the name of the archive. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
MiriamSapir Posted August 15, 2011 Author Posted August 15, 2011 You don't need the log if you are not going to use it - it is useful and personally I don't see any reason to NOT use it. Only several lines in the script - won't hurt at all. If you don't want logging - just comment the lines. The message box is there just to show that the archiving will be done - just comment that and it will be fine. Do you mean this? If you will use the log - it is necessary because it will write the appropriate message (success/fail) If the file has the same name, same path - when you zip-it it will overwrite the old one - if you want that - then it's OK. If not - you will need to change the name of the archive. Thanks for the quick reply. Is this how the script is supposed to look like? #include <Process.au3> $Hong_Kong_Polytechnic_HKP_New_Journals_Books.txt=IniRead(@C:\Sunday Reports\August-14-2011\FTC & "\Options.ini", "ZIPFILES", "FilesToZip", 0) _Zipfiles($Hong_Kong_Polytechnic_HKP_New_Journals_Books.txt) ; run function Func _Zipfiles($C:\Sunday Reports\August-14-2011\FTC) $a = FileGetShortName($C:\Sunday Reports\August-14-2011\FTC) $Zipto=IniRead(@C:\Sunday Reports\August-14-2011\FTC & "\options.ini", "ZIPFILES", "WhereToZip","''") $zipPath='"C:\Program files\WinZip\WZzip"' & ' -m ' & $Zipto & " " & $C:\Sunday Reports\August-14-2011\FTC & ' -ybc' Endfunc Thanks, Miriam
enaiman Posted August 15, 2011 Posted August 15, 2011 Nope - you have messed up the script. If you will need to do further work in AutoIt - you better start learning from examples in the help files, also check some tutorials too. This is how it is supposed to be: #include <Process.au3> $filestozip = "full path to file I want to zip" ;example: "C:\my files\abcd.txt" $ArchiveName = "full path to archive I want to use" ;example: "C:\my archive\test.zip" _Zipfiles($filestozip) ; run function Func _Zipfiles($sFile) $zipCMD = '"C:\Program files\WinZip\WZzip"' & ' -min -a "'& $sFile & '" "'& $ArchiveName & '"' $rc = _RunDos($zipPath) Endfunc You need to replace file name and archive name and it should work. WinZip command line is for adding the file to the archive - for other options - check WinZip command line parameters. After you fill in the info, run the script and check the archive, the file should be there. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
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