how would I zip files?

themacko

Barking at the moon.
This is a bit a newbie question (maybe) but I've never tried this on my Mac. I've got a bunch of pictures that I am going to sending to friends whom mostly are using using Windows, but at least one is on a Mac (not sure which OS).

Anyhoo, how would I go about zipping up these files? I opened up Stuffit but it only has the option to 'expand.' I'm pretty sure I can do this through the Terminal using UNIX commands, but I don't have a clue how! Any help would be GREATLY appreciated. Thanks!
 
You're right that there is a commandline interface zip program included in OS X.

the short answer - if the files you want are all in the folder "photos"

zip -r photos photos.zip

will get everything in that folder into one zip file. You have to be at the same level as the folder full of photos, obviously - ie. if the folder is on the desktop, then first "cd Desktop" when you open the terminal.

the long answer - for all the possible options to the zip program, type

zip -h

to get the semihelpful help screen
 
Aussie John is right-- download Stuffit Lite from download.com or directly from Aladdin at http://www.aladdinsys.com/ ... It includes a program called 'DropZip' (as well as DropStuff and DropTar). Just drag a file or folder onto this application to zip it.

...the 'zip' command of course is always there in the command-line, this is just a little bit more friendly.
 
yes- I should have been a bit more expansive in my reply but was rushed for time.
What I do is drag the application icons to the tool bar. Presto - compression and expansion is all at your finger tips in the finder window for grag and drop.
Just another tip- I always turn off in preferences of drop zip - Macbinary to "never" as it seems to work with PC users all the time.
 
I also used DropZip for some time, but then my lite version ran out, and I couldn't use it anymore.

I don't see why I should pay for just a simple thing like zipping files, and did it via Terminal for some time.
Recently, I made myself a nice Toolbar Applescript for this, so I just can drop the files on the Icon, and I don't have to pay for this.
:p
 
Originally posted by Aussie John
it ran out?
after how long?
When you start the Application it says "Using this program longer than 15 days requires registering"
 
Originally posted by Tigger
I also used DropZip for some time, but then my lite version ran out, and I couldn't use it anymore.

I don't see why I should pay for just a simple thing like zipping files, and did it via Terminal for some time.
Recently, I made myself a nice Toolbar Applescript for this, so I just can drop the files on the Icon, and I don't have to pay for this.
:p
Could you post your AppleScript?
 
Here, lemme whip up a simple AppleScript to do the job, using the command-line:

(Start time 21:45:40)
(Stop time 22:38:00)

OK so it took longer than I thought... :p

Here's an applet for zipping a file:

choose file with prompt "Choose a file to zip:"
set filepath to result as string
do shell script "echo " & filepath & " | tr : /"
set pathpath to result as string
set AppleScript's text item delimiters to {"/"}
set num to number of text items of pathpath
set filename to text item num of pathpath as string
set pathpathpath to text items 2 through (num - 1) of pathpath as string
do shell script "cd " & pathpathpath & "; zip -r zipfile.zip '" & filename & "'"


Here's one for zipping a folder:

choose folder with prompt "Choose a folder to zip:"
set folderpath to result as string
do shell script "echo " & folderpath & " | tr : /"
set pathpath to result as string
set AppleScript's text item delimiters to {"/"}
set num to number of text items of pathpath
set filename to text item (num - 1) of pathpath as string
set pathpathpath to text items 2 through (num - 2) of pathpath as string
do shell script "cd " & pathpathpath & "; zip -r zipfile.zip '" & filename & "'"


Here's how to make it into a droplet (the file one):

on run
choose file with prompt "Choose a file to zip:"
set filepath to result as string
do shell script "echo " & filepath & " | tr : /"
set pathpath to result as string
set AppleScript's text item delimiters to {"/"}
set num to number of text items of pathpath
set filename to text item num of pathpath as string
set pathpathpath to text items 2 through (num - 1) of pathpath as string
do shell script "cd " & pathpathpath & "; zip -r zipfile.zip '" & filename & "'"
end run

on open these_items
do shell script "echo " & these_items & " | tr : /"
set pathpath to result as string
set AppleScript's text item delimiters to {"/"}
set num to number of text items of pathpath
set filename to text item num of pathpath as string
set pathpathpath to text items 2 through (num - 1) of pathpath as string
do shell script "cd " & pathpathpath & "; zip -r zipfile.zip '" & filename & "'"
end open


Save this as an applet, and it will automatically inherit the properties of a droplet. I don't think that it will accept multiple items, though. If you want to zip multiple files, first put them into a folder, and then use the folder zipping script (you can convert that to a droplet similar to the file one). It'll also choke if there's a / somewhere in the path (Mac OS X's finder accepts slashes, but actually puts them as colons for some reason -- there's no way to correct for this in an AppleScript).
 
Here is my Script.
You can also put more than one file on it, and it will zip them, asking you what the zip archive should be named.
When you just klick on it without throwing any files on it, you can change some prefs like the how good it will compress, and the default archive name for more than one file.

It also works with files and folders.

I use the POSIX file function, so my script will only run on Mac OS X 10.1.2
 

Attachments

  • zip files.zip
    1.7 KB · Views: 15
Back
Top