Mac Terminal Zip Multiple Files


Place the Files you wish to Zip within the folder. Select the Search Icon in the upper right corner. Search for the Terminal. Select Terminal. Enter zip -er NAMEOFZIPFILE.zip; Enter a space. Drag and Drop the Folder on the desktop into the terminal. Select Enter/Return. Enter a Password. Jul 14, 2020 Here's how: Open the folder with files or folders you want to zip up Select the items you want to include in the zip file and right-click on any one of the items. Select 'Compress (x) Items' from the pop-up menu.

Zip multiple files into individual archives via Automator | 19 comments | Create New Account
Click here to return to the 'Zip multiple files into individual archives via Automator' hint

Use the -s switch on the zip command in terminal. So if your folder was called FolderName. Zip -r -s 64 archive.zip FolderName/. 64 is the size of the split (in this case 64Mb). Use -s to set the split size and create a split archive. The size is given as a number followed optionally by one of k (kB), m (MB), g (GB), or t (TB) (the default is m). To extract a split zip archive (a series of files named zip, z01, z02.), run following command in Terminal: First, combine the split archive to a single archive: zip -s 0 split-foo.zip -out unsplit-foo.zip. Extract the single archive using unzip: unzip unsplit-foo.zip.

The following comments are owned by whoever posted them. This site is not responsible for what they say.
Zip multiple files into individual archives via Automator

for folders, try the -r option ..
zip -r '$f' $f'
from the man page -- a little confusing that the args are 'foo' and 'foo'. the first arg is turned into 'foo.zip' .. the second arg is the file spec (of files which will be placed into the .zip)
~~~
To zip up an entire directory, the command:
zip -r foo foo
creates the archive foo.zip, containing all the files and direc-
tories in the directory foo that is contained within the current
directory.
~~~

Zip multiple files into individual archives via Automator

Okay I must be doing something wrong because I did try to mix this hint (zip individual files) with the folder argument and it's not working...
I try both:
--
for f in '$@'
do
zip -r '$f' $f'
done
--
and
--
for f in '$@'
do
zip -r '$f.zip' '$f'
done
--
whitout any luck... :( I must admit I'm not used to play with Automator and Run Shell Script...

Zip multiple files into individual archives via Automator

Never mind.
I just tried the script for individual files with folders selected and it work just the same (~/foo/bar with foo selected become ~/foo.zip). Doh!

Zip multiple files into individual archives via Automator

Okay, one last thing... ;)
When I zip a folder with this script, let's say /foo from the Desktop level (~/Desktop/foo),
everything is working fine, i.e. it gives me a file named foo.zip at the same level as my original /foo folder (~/Desktop/foo).
The problem is when I unzip it. I end up with nested folders, i.e. /Users/MyUserName/Desktop/foo on the ~/Desktop folder. Is there a way to not include all those (almost empty) folders in the script?
The idea would be to make the script behave just like the 'Create Archive of...' in the contextual menu

The Automator workflow One Zipper does the same thing, but uses the cleaner 'xargs'. It's saved as a droplet, but can easily be converted to use as a contextual menu item.

---
www.automatorworld.com
'Better Living Through Macintosh Scripting'

Zip multiple files into individual archives via Automator
Files

IMHO it is better to just throw them in a folder and zip the folder. It's my pet peeve when a bunch of files unzip and end up all over the place as individual files. I'd rather unzip them into a nice folder.

using filetests to zip both files and directories transparently
In order to make this automator work flow work transparently with both files and directories, use file tests, like so: Have not tested, but should work just fine.

---
The Apotek
http://theapotek.com
The Executioner's Summary:
http://www.last.fm/label/Broken+Hill+Music/playlists/6761?autostart

using filetests to zip both files and directories transparently

Sorry, does not seem to work. Added .zip to two places and it would partially work.
However, what would be nice is to have the workflow go like this:
Set up: single file on desktop, folder on desktop with some files in it and another folder in it with some more file (i.e. a level 2)
Now, results: run the work flow and have it zip the single file. Next, it would zip the folder and the subfolder. This does not happen now - no second level.
Also, would like to stip the path out of the zip file just to the folder level. For the single file a -j seems to work. However, how do you get the file path to just start at the folder being zipped, not at the user/desktop/etc level when unzipping?
Can this be done?

Zip multiple files into individual archives via Automator
I use a workflow with the following script, which does the following:
  1. Handles both files and directories
  2. Uses bzip2 instead of zip (better compression)
  3. Files are replaced by original_filename.bz2
  4. Directories are replaced by original_directoryname.tar.bz2
  5. In the event of an error, the original is not deleted
  6. File names are quoted properly to take into consideration embedded blanks which would mess up other solutions I've seen
Zip multiple files into individual archives via Automator

I would love it if this action worked, it would be perfect as i agree, i would like the extra compression afforded by it, however it simply does not work. . . do you think you could go over exactly what i should do in the automator terminal? as in should it be '/bin/bash' and 'asas arguments' ? also i copied your code exactly and pasted it in the script box, perhaps i was supposed to do something else as well? thanks.

Zip multiple files into individual archives via Automator

So many years have gone by and I still haven't found any better script to what our script does!
There is only one problem, when applied through Automator (on 10.6.8 or 10.5) is crashes after it compresses the 1st folder. Do you any idea why or if there is anything one can do to avoid this problem?

Zip multiple files into individual archives via Automator

Chas, you are missing the point.
Let's say you have a game emulator and you have 1500 roms. The emulator accepts .zip and if you zip all of the roms you save a significant amount of space.
Zipping all of the files into a single zip will not work as the emulator will probably only load the first file in the zip.
This hint is very useful for us emu geeks.

Zip multiple files into individual archives via Automator

This seems to work, but it only works if you select an entire folder and run the automator scrpt from there, otherwise if you select individual files it actually searches each file for folders and zips the files within the 'package contents' : so workflow looks like this:
in the automator place action 'get selected finder items'
followed by 'get folder contents'
followed by 'run shell script' : keep the shell as /bin/bash and the pass input as 'to stdin' the actual script is
xargs -I {} zip {}.zip {}
that's it. save the workflow as a finder selection and select a folder full of files you wish to individually compress, and it works but yes unfortunately it still makes it have that annoying files structure, which i personally can't stand, and also it doesn't seem to like working with other folders within folders and it can't seem to compress .apps very well, lastly i would like to have the option to individually select groups of files from within a folder and zip those.i dunno what's up with that. so maybe someone can take this script and flesh it out? :)

Zip multiple files into individual archives via Automator

thanks, useful tip.
does anyone know a way to get around the directory structure... at the moment i have to dump my folders in the root dir to avoid the problems unzipping.

Zip multiple files into individual archives via Automator- and use encryption

and what if you want to encrypt each file with the same password?
just adding the -e-argument fails for obvious reasons.. so how?

Zip multiple files into individual archives via Automator
A solution that works on Leopard by running an AppleScript instead of a Shell script can be found here:
http://discussions.apple.com/message.jspa?messageID=7079445

Mac Terminal Unzip All Files In Folder

Mac terminal unzip all files in folder
Zip multiple files into individual archives via Automator
Can someone help me with the reverse of this? I have a folder with several zip files, would like to select all, run script to unzip each in the same folder as the zip files Everything I have tried, resorts to unzipping to the root of the user's home directory. Here is where I sit right now...
Zip multiple files into individual archives via Automator

found this tip via Google. you have no idea how much time you just saved me.
i actually prefer using Terminal/Shell for zipping files...some people with older Windows systems seem to struggle with zip files made on a Mac and using the shell helps.

Zip multiple files into individual archives via Automator
will zip individual folders without the nested (absolute path) directory structure. Also, in Automator, make sure the 'Pass Input' pulldown is set to 'as arguments'.

When you first purchased your Mac, one of the biggest deciding factors you considered is most probably disk space. But as years go by using your computer, its disk space seems to become smaller and smaller by the day, no matter how diligently you delete unneeded files and unused programs. In the computing world, one could never have too much storage space. There are some ways you could save space on your Mac, including manually deleting files and programs or automatically doing so with the help of apps designed to clean out junk such as Mac repair app. Another way — albeit less popular — to free up Mac space is to compress and zip files. In this article, we’ll show you how to zip a file on Mac, unzip it, and protect it with a password.

How to Zip a File on Mac

Converting any standard file to a compressed zip file the traditional way is effortless. You can do this to photos, videos, audio files, and documents, among others. Here are the steps:

  • In Finder, look for the file or folder you want to compress and zip. Right-click or Ctrl-click on it.
  • Select “Compress [name of file or folder].”
  • Wait for the compression process to finish. Larger files may take time to end compressing.
  • Once done, a new .zip file will appear in the same location as the original file or folder. You will also hear a system alert tone to notify you of the recently completed compression.

You can now send these compressed files or folders via email. You may also choose to delete the original files and folders if you want to save on disk space, but note that you can’t readily open or view the zipped versions. You’ll need to unzip them first (more on that later).

Pro Tip: Scan your Mac for performance issues, junk files, harmful apps, and security threats
that can cause system issues or slow performance.

Free Scan for Mac Issues
410.674downloads

Special offer. About Outbyte, uninstall instructions, EULA, Privacy Policy.

How to Zip Multiple Files on Mac

You can also compress multiple files and/or folders. Here’s how:

  • First, you have to create a new folder in Finder or Desktop. Press Shift + Command (CMD) + N).
  • Name the new folder.
  • Drag the files you want to zip together to the folder you just created. IMPORTANT: Before dropping the files, hold down Alt to make sure that the files are copied to the new folder.
  • Once all the files you want to zip together are in the folder, Ctrl+Click on the folder, then choose Compress.
  • A new zip file should now be created.
  • Drag the folder (not the zip file) you created earlier to the Trash.

How to Change the Save Location of Your Zip Files

By default, a zipped file or folder will be saved in the same place where the original is saved. But, you may also choose a dedicated destination for all of your compressed files. It is done by opening the compression app. In Mac, it’s called the Archive Utility. A simple Spotlight search can easily find it. After searching for the app on Spotlight, open it. Click the Archive Utility drop-down menu at the top of the screen, then click Preferences. Select the menu named Save archive, then select into. Next, choose your desired destination.

How to Open and Unzip a Zip File on Mac

Opening a zip file to view its contents is pretty straightforward. Just double-click on the file, and it will open. The zip file can still be seen in the location folder, but an unzipped copy will also be created in the same location. Meanwhile, if were sent a compressed file in a format other than zipping, such as .rar, you’ll need to use an app to decompress it, such as The Unarchiver. You can get this app for free from the App Store. Once installed, the app automatically works pretty much exactly like your Mac’s built-in zip tool. Just double-click the archive file, then the files and folders will be extracted and saved in the same location as the archive file.

How to Enable or Disable a Browser From Extracting Zipped ‘Safe’ Files Automatically

Mac Terminal Zip Multiple Files

Some web browsers, such as Safari, automatically unzip downloaded compressed files that they consider to be safe by default. In Safari, these safe files include movies, pictures, sounds, PDFs, text documents, and archives. However, if you prefer to decompress downloaded zip files yourself, you can opt out of this feature.

Mac Terminal Zip Multiple Files Into One

In Safari, go to the drop-down menu. Locate and select Preferences, then click the General tab. Down below the window, you will see “Open “safe” files after downloading.” Leave the box checked if you want Safari to decompress these safe files automatically. Otherwise, untick the box.

How to Protect Your Zip Files With a Password

Now, here’s the more challenging bit. If you want to conceal some of your files, you can do so protecting it with a password. It is an excellent solution for highly confidential files since you probably won’t bother going through the quite complicated process to protect regular files. You may also do this for files that you are about to send through an unsecured messaging or mailing system. When you encrypt a zip file or folder, anyone who is trying to access the file using whether a Mac or PC will have to enter the password you create. To protect your zip file with a password, you’ll have to do it in the Terminal. As an example, let’s assume that the file is named softwaretested.jpg. Now, follow these steps:

Terminal
  • Open Terminal by going to Applications > Utilities > Terminal. You may also search for it on Spotlight.
  • Type in cd Desktop then hit Enter/Return.
  • Type in zip -e softwaretested.zip softwaretested.jpg, then hit Enter/Return.
  • At this point, Terminal will ask you for the password. Type in the password you have in mind. Note that it will appear as if nothing is happening, but it’s designed this way so that the password will be concealed.
  • When done typing the password, hit Enter/Return.
  • The Terminal will ask you to verify the password. Type it again, then hit Enter/Return.
  • Let Terminal finish the job. Status progress will be shown in the form of a percentage. When done, close the Terminal window.

A Note on Naming Your Zip Files

If you plan to protect a zip file or folder with a password, it is recommended that you don’t put spaces on the file name as much as possible. Telling the Terminal to password-protect a file with a name that has spaces will require you to do extra work. For instance, if your filename is software tested.jpg, you’ll have to type the code so as:

zip -e software tested.zip software tested.jpg

Zip Into Multiple Files

It’s not that difficult, but you should take extra caution whenever dealing with a file with spaces on its filename.

How to Password-Protect a Zip Folder

Mac Terminal Zip Multiple Files

If it’s a zip folder you want to put a password on, change the -e extension to -er. For instance, zip -er softwaretested.zip softwaretested.

Online

How to Open a Password-Protected Zip File or Folder

Zip File Mac Free

If you were sent a password-protected zip file or want to open your encrypted files, just double-click on them as usual, then enter the password when asked.

Open Zip File Terminal

Zipping files on Mac is just one of the ways you can save space on your computer and compress big files and folders before sending them to someone else. Know of other file compression tips and methods? Share them with us in the comments below!