Link to home
Start Free TrialLog in
Avatar of Bob Collison
Bob CollisonFlag for Canada

asked on

WinZip Command Line - Exclude Folders

Hi Experts,

I have a .bat file that is used to backup data.  I want to include all folders / files on a drive but exclude one folder.  I can't seem to get it to do the exclusion.

Here is the WinZip Command Line.

"C:\Program Files\WINZIP\WZZIP.EXE"  -xd\\PL1\PL1-G-Data\Photos\*.*   "Z:\PATLAPTOP1\PL1-G-Data\%date%\PL1-G PatData All.ZIP" "\\PL1\PL1-G-PatData\*.*"  -r -p

Explanation
- Job is run on the PC where the 'Z:' Drive is located.
- Drive to be zipped is on PC \\PL1.
-  The Drive to be zipped is PL1-G-PatData.
- Folder (with sub folders) that needs to be excluded is PL1-G-Data\Photos

What needs to be done to get it exclude the PL1-G-Data\Photos folder.  Right now there are no errors but it is including the Photos folder?

Note: If using an 'Exclusion Parameter File' is a better way them I ok with it.

Thanks,
Bob C.
Avatar of Bob Collison
Bob Collison
Flag of Canada image

ASKER

Hi Experts,

Could someone please comment on this question?

Thanks,
Bob C.
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
You can use a wildcard, as described in the documentation:

-x<filename> Exclude the specified file(s) from the zipping process. Wildcards are allowed.
  wzzip -x*.txt d:\temp\test.zip *.*
Creates test.zip and includes all files in the current folder except .txt files.

  wzzip -xd:\taxes\2004\*.* d:\taxes\taxarchive.zip d:\taxes\*.*
Creates a Zip file in d:\taxes called taxarchives.zip and includes all folders and files in the d:\taxes folder structure EXCEPT the folder d:\taxes\2004.

Note: -x*\ can be used to exclude empty folders.
Hi Experts.

Unfortunately I can't access the PC that I run this on so testing will have to wait until later today.

In the mean time I have noted that maybe the quotes " are not correct as they are on some of the statements but not all.  What do you think?

Thanks,
Bob C.
Quotes are only required when you have embedded spaces, as in "Program Files" in the command part of the line.  While it is not likely that the %DATE% environment variable has spaces, since you don't know for SURE, quotes are recommended.
Hi Experts,

Thanks for your suggestions.

I have been trying to get this to work and have created a simpler .BAT File (as .txt) that I am attaching below.

The 'Junk' folder contains a few files plus one subfolder 'Jokes'.

The current code in the sample is still including the 'Jokes' folder that I want to be excluded.  I have tried this with and without the 'x' as suggested by Bill Prew.

Please take another look and let me know any further ideas.

Thanks,
Bob C.
AA-Test-Exclude-Folder.txt
Don't include the quotes around the -x here: "-xd:\Junk\Jokes\*.*", as this will mess up the parser looking for the dashes.
If you DO need quotes, then try this instead: -x"d:\Junk\Jokes\*.*"
However, since there is no embedded space in that string, you are best off leaving the quotes off: -xd:\Junk\Jokes\*.*

Note that this MIGHT still include the empty Jokes folder.  You might ALSO need to add this: -xd:\Junk\Jokes
Thanks Bill,

I have tried each of the following without success.
-xd:\Junk\Jokes\*.*
 -x"d:\Junk\Jokes\*.*"
-xd:\Junk\Jokes

Any other ideas?
Thanks,
Bob C.
Avatar of Bill Prew
Bill Prew

Traveling this morning, will try some test cases here later today...

~bp
ASKER CERTIFIED SOLUTION
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
SOLUTION
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