PDA

View Full Version : Automating compression (All)



aveerara
02-26-2004, 01:31 PM
I want to automate a process that we perform every month, compressing certain files in a specific folder (using winzip right now) and deleting those files. I am currently looking into using WSH to automate that task. I am new to windows scripting.

Currently, at someone else's idea, I am planning on using the Exec function to run winzip command line utility. I have the code, but it doesn't work completely.

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("wzzip "Path where I want the zip file to be\test.zip" "Path to the folder where te zip files to be zipped are"")

When I just say the zipfile name, it puts the destination on the desktop. I need the destination to be at one particular path. Also, I tried to cd to that path using another Exec command, but it doesn't work. It gives me an error. Help please.

Note: There are three sets of quotes. One around the entire command, one around the destination file and the third around the source file. I tried various combinations with and without double and single quotes. None works.

Note 2: Apparently, the script doesn't recognize the multiple quotes used. Is there any way around that?

If it is not possible to achieve this project this way, is there a better way of doing this?

I am not particular about the winzip app. I can change it if it is easier with any other compression utility. Thanks in advance.

Brf
02-27-2004, 07:29 AM
To represent a quote symbol in a string, you replace it with double quote ("") so your string should look like this:

("wzzip ""Path where I want the zip file to be\test.zip"" ""Path to the folder where te zip files to be zipped are""")

Note there are three quotes at the end because the first two quotes represent the quote-character and the third quote terminates the string.

aveerara
02-27-2004, 01:08 PM
Thanks for the post. The double double-quotes worked... partly.

The source path worked just fine, but the destination path didn't.

Set oExec = WshShell.Exec("wzzip ""C:\Documents and Settings\ananth.narayanan\MyDocuments\Projects\Pat ch Management\test.zip"" ""C:\Documents and Settings\ananth.narayanan\My Documents\Projects\Patch Management\*.doc""")

didn't work, whereas

Set oExec = WshShell.Exec("wzzip test.zip ""C:\Documents and Settings\ananth.narayanan\My Documents\Projects\Patch Management\*.doc""")

worked. However, the second statement put the test.zip on the desktop. Do u see anything I am doing wrong?

Brf
02-27-2004, 01:37 PM
You forgot the space in "My Documents" in the first parameter>

aveerara
02-27-2004, 01:39 PM
Yup. Thats right. I just figured it out. And I came to delete my previous post, but u had already read it... sorry...