Zip files via cmd ?

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

I know XP cqn create zip files from the GUI, but can it do it from a cmd environment ?

Andy
 
Andy explained on 11/26/2012 :
I know XP cqn create zip files from the GUI, but can it do it from a cmd
environment ?

Andy

Look at 7-Zip. It has both a Windows and command line app.
7-Zip is compatible with WinZip and Windows.
 
OldGuy said:
Andy explained on 11/26/2012 :

Look at 7-Zip. It has both a Windows and command line app.
7-Zip is compatible with WinZip and Windows.

After you install 7-ZIP, look for the file "7-zip.chm"
in the Program Files folder for it. Double-click
on the .chm to display the Help window. In there
are instructions for how to craft a command line
invocation.

Don't be surprised if it takes you a while to get
the command options right. If you point it to a
directory, it automatically recurses (captures the
whole directory tree you point it at). The wild card
options might not work the way you expect either.
So be prepared for the odd surprise.

7ZIP has command line options for the "container" and
the "compressor". Some containers have multiple options
for compressors.

There are some examples on this page as well.

http://linux.die.net/man/1/7z

Using the examples there, in Windows I might start with

7z --help

7z.exe a -tzip archiveoutput.zip *.txt

That would store all the *.txt files in archiveoutput.zip

The Linux version is a port of the Windows version, but
there's a good chance it shares something in common
with respect to options.

When I need to compress really large files, I sometimes
use other programs for that, as the best space-time tradeoff.
7Zip only uses multiple cores on some compression algoritms
and not all. The utility "pigz.exe" is a GZIP compressor that
uses multiple cores, and I like "pigz -3" as a level of
compression for disk sized jobs. The Windows version of pigz
has its issues, so if I want something I know will work well,
I switch over to Linux and run their version. If I use
7ZIP, and use the very best compression options for space,
it could take up to a week to complete, depending on what
I'm doing. At first, the lure of high compression looks like
a win, until you begin to realize how long it will take.
For small jobs though, this isn't an issue. If you need to
compress a gigabyte of stuff, you probably don't care.

HTH,
Paul
 
Yes, it can be rather tricky getting all the parameters formatted
correctly, especially when double quotes are required for parameters
with spaces in them.
 
Per Andy:
I know XP cqn create zip files from the GUI, but can it do it from a cmd environment ?

This may be moot in light of the freebie zip utilities already
mentioned, but I've been using WinZip (something like $12.00) and
it's command line companion to automagically zip files.

- Make up a .BAT file:

"c:\program files\winzip\wzzip.exe" -a -sWhateverPW -ycAES256
"%~d1%~p1%~n1.zip" %1


- Create a shortcut icon to said .BAT file

- Drag/drop any file on to the icon

- The .BAT file automagically creates a like-named
password-protected .ZIP file in the same directory
as the source file.


OTOH, for bulk un-zipping of PW-protected .ZIP files (all with
the same PW) I could not get anywhere with the WinZip command
line and resorted to 7-zip:

"C:\Program Files\7-Zip\7z.exe" e -pWhateverPW %1 -od:\Temp2

I never could get it working in a .BAT file and had to resort to
pasting this into a command line window:

for %I in (*.zip) do "C:\Program Files\7-Zip\7z.exe" e
-pWhateverPW %I -oW:

That unzipped all files in the current directory to the root of
drive W:. Not pretty, but it worked for the one time I
needed to do a batch un-zip.
 
Back
Top