WinZip Command Line - Exclude Folders

Bob Collison
Bob Collison used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bob CollisonSystem Architect

Author

Commented:
Hi Experts,

Could someone please comment on this question?

Thanks,
Bob C.
Bill PrewTest your restores, not your backups...
Top Expert 2016
Commented:
I don't believe -xd is a valid option, only -x.

Try the following:

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

Open in new window


»bp
Bill BachPresident and Btrieve Guru

Commented:
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.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Bob CollisonSystem Architect

Author

Commented:
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.
Bill BachPresident and Btrieve Guru

Commented:
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.
Bob CollisonSystem Architect

Author

Commented:
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
Bill BachPresident and Btrieve Guru

Commented:
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
Bob CollisonSystem Architect

Author

Commented:
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.
Bill PrewTest your restores, not your backups...
Top Expert 2016

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

~bp
President and Btrieve Guru
Commented:
I think the problem is with the fully-specified path in the exclusion.  (Also, you still listed the D: drive, although you were excluding files from G:\Junk instead of D:\Junk.)  Eliminating the full path definition seems to be the trick here.  The following worked for me (and excluded the Jokes folder):
@ECHO OFF
ECHO * * * * * * * * * * * * * * * * *
ECHO * 100   Backup Test.            *
ECHO * * * * * * * * * * * * * * * * *
ECHO.
G:
CD\Junk
DEL Test.ZIP /q
Rem WinZip Documantation example. wzzip -xd:\taxes\2004\*.* d:\taxes\taxarchive.zip d:\taxes\*.*
Rem My Orginal Code. "C:\Program Files\WINZIP\WZZIP.EXE"  -xd\\PL1\PL1-G-PatData\Photos\*.*   "Z:\PATLAPTOP1\PL1-G-Data\%date%\PL1-G PatData All.ZIP" "\\PL1\PL1-G-PatData\*.*"  -r -p
Rem Next line is new EE Code.
Rem "C:\Program Files\WINZIP\WZZIP.EXE"  -x\\PL1\PL1-G-Data\Photos\*.*   "Z:\PATLAPTOP1\PL1-G-Data\%date%\PL1-G PatData All.ZIP" "\\PL1\PL1-G-PatData\*.*"  -r -p
Rem Works without excluding Folder. "C:\Program Files\WINZIP\WZZIP.EXE"  "G:\Junk\Test.ZIP" "G:\Junk\*.*"  -r -p
"C:\Program Files\WINZIP\WZZIP.EXE"  Test.ZIP *.*  -r -p -xJokes\*.*"
Rem PAUSE
ECHO.
ECHO * * * * * * * * * * * * * *
ECHO * 999   Job Completion.   *
ECHO * * * * * * * * * * * * * *
ECHO.
ECHO Backup is complete.
ECHO.
EXIT

Open in new window

Bob CollisonSystem Architect
Commented:
Hi Bill,

I contacted WinZip and they provided the following solution.

They also advised that the exclusion statement should be at the end rather than near the beginning of the command line.
"C:\Program Files\WINZIP\WZZIP.EXE" -rp G:\Junk\Test.ZIP G:\Junk\*  -xG:\Junk\Jokes\*

I finally caught on bout the 'D' Drive being a drive letter which for some reason I was interpreting as a WinZip parameter.

Thanks for all your assistance.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial