Link to home
Start Free TrialLog in
Avatar of blastmasterJUS1
blastmasterJUS1

asked on

WZZIP command line tool

HI there. I'm using the WinZip command line tool WZZIP and I'm a batch file noob.

I'm trying to write a batch file to zip folders that are dropped in "c:\For Zip" and place them in "C:\Zipped Folders".
I need to end up with seperate zip files for each of the folders under the "For Zip" directory.

For example, right now I have the following folders:
c:\For Zip\Folder1
c:\For Zip\Folder2
c:\For Zip\Folder3
etc

I need to end up with:
C:\Zipped Folders\Folder1.zip
C:\Zipped Folders\Folder2.zip
C:\Zipped Folders\Folder3.zip
etc

The following creates one single zip file called TEST.Zip in the "ForZip" directory. How can I create the multiple zip files. A loop of some sort?

@echo off
wzzip -p -r "C:\For Zip\test.zip" "C:\Zipped Folders\*.*"      

Any help is appreciated. Thanks.
Justin
Avatar of Bill Prew
Bill Prew

In a BAT file, should be as simple as this:

@echo off
for /D %%A in ("c:\For Zip\*") do wzzip "C:\Zipped Folders\%%~nA.zip" "%%~A\*.*"

Open in new window

~bp
Avatar of blastmasterJUS1

ASKER

Thanks Bill! This seemed to only zip the batch file, which was sitting in the "For Zip" folder along with the sub folders (the ones I want to zip).

 I played around with it for a while and the closest I could get was to end up with the correctly named zip files (Folder1.zip, folder2.zip, etc) in the correct destination folder ("Zipped Folders") however, each zip file contained each one of the folders and the batch file, which was in the directory this time as well.

Any suggestions?

@echo off
for /D %%A in ("C:\FOR ZIP\*") do wzzip -p -r "C:\ZIPPED FOLDERS\%%~nA.zip"

Thanks again.
Justin
Can you make this change to my prior post and tell me what it displays when you run it:

@echo off
for /D %%A in ("c:\For Zip\*") do ECHO wzzip "C:\Zipped Folders\%%~nA.zip" "%%~A\*.*"

~bp
Bill, your initial post does indeed work, I didn't see the last part of line 2..my goof!

Anyway, I'm just about there, just one small issue. I ended up with the zip files named correctly (folder1.zip, folder2.zip, etc) andf they contained the correct files and sub folders however, the zip did not include the top level folder (folder1, etc).

i.e.
folder1.zip
contains all of the files and folders under folder1 but I would like folder1 to be zipped so that when I open the zip file I see folder1 sitting in there, and the various files and subfolders would be contained within folder1. Does that make sense?

Thanks again for all of your help!
Justin
Give this a try, not positive if it will give you what you want but I think it should.

@echo off
for /D %%A in ("c:\For Zip\*") do wzzip -P "C:\Zipped Folders\%%~nA.zip" "%%~A\*.*"

Open in new window

~bp
Bill, thanks again for your expertise...that last piece zipped the whole "For Zip" directory into folder1.zip, the same for folder2.zip, and then folder3.zip contained the sub directories of folder3 for some reason...

This line below seems to work best however, I'm still ending up with the contents of Folder1 in the folder1.zip..what I need is Folder1 itself to be zipped along with it's contents. So that , when I open Folder1.zip, I would see Folder1 only (it's contents included within), not the contents of folder1.


@echo off
for /D %%A in ("c:\For QC AND RESCAN\*") do wzzip -p -r "C:\FOR INDEXING\%%~nA.zip" "%%~A\*.*"


Justin

 
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for taking the time!
Beautiful!

Thanks again!
Great, glad I was able to help, thanks.

~bp