Zipping Files for Distribution: on Mac & In a Batch on Windows 

A lot of users don’t understand the sometimes lack of interoperability of zip files depending on how they zip things. In other cases, someone might know that automating or batch zipping is possible but don’t realize how easy it can be.

The Problem: Using Compress on a Mac

While Apple has made it really easy for Mac users to “Compress” files, the problem is that the file is a .zip and many users think it’s a standard zip.

Unfortunately, more than once I have encountered zip files compressed on a Mac that won’t even unzip on Windows. When it does, many Windows users get confused by all the extra files and folders that they don’t expect and don’t know what to do with.

The Solution

The easiest solution would be to install  a program that zips without all the extra Mac stuff. I’ve heard good things about both Unarchiver and ClamXav though I haven’t tried either.

The other solution is to use the Terminal.

After opening Terminal, browse to the folder where your file/folder sits. If you’re new to the command line, check out this guide on basic commands.

Use the following to zip your file or folder:

zip -r -X archive_name.zip folder_to_compress

It might seem like a lot of trouble to zip just one file or folder but I put it here mostly for reference since the next section on batch zipping should be easily adaptable with the basic zip command. (I say should because I never got around to it myself. )

Batch Zipping on Windows

Much like zipping on a Mac, you can zip files on Windows using the command line.

However, you’ll need to install a command line tool. I use 7zip and find it better than the built-in Windows one in general.

Using Command Prompt

In Command Prompt, browse to the folder that contains all the folders or files you want to zip. Then use this command to batch zip everything:

for /d %%X in (*) do “c:\Program Files\7-Zip\7z.exe” a “%%X.zip” “%%X\” -tzip

You can also change a lot of the settings by adding switches allowed in 7zip.

Remember this is meant to zip each folder or file inside the folder you’re in so don’t have anything else in there.

If like in my case you’re worried about programs or apps that can read content inside zips but not if the files are inside a folder then you can use a more complex version that will go inside each folder zip the contents using the folder name then move the zip into your parent folder:

for /d %%X in (*) do (cd “%%X” && “C:\Program Files\7-zip\7z.exe” a “%%X.zip” * -mx=5 -tzip && move “%%X.zip” .. && cd .. )

Without Using Command Prompt

Let’s improve the process so you don’t need to open Command Prompt to type in the command all the time.

  1. Open Notepad.
  2. Copy the appropriate command from above.
  3. Save the file with your choice of filename with extension .cmd inside the parent folder.
  4. Double click to run it.

Now, any time you want to batch zip folders just move or copy the file to the parent folder and run it. 

Published by

Cynthia

A librarian learning the ways of technology, accessibility, metadata, and people

Leave a Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s