Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Mac OS X uses zip as it's default compression format. It makes this conveniently available from the contextual menu (control-click/right-click). I'd like to adjust this default to bzip2.

I can do this via the command line with...

tar cfj something.tar.bz2 something

... I could even wrap that in an Automator action or such, but it would be nice to just adjust the default. Any ideas?

TIA

share|improve this question
    
If you know Objective-C, you could try using SIMBL to inject your code into the Finder. To find out what you exactly need you can use F-Script, which allows inspection of running applications and injection of code in run time. After you install and configure it, attach to the Finder process (as root), and open the Object browser. In a couple of minutes you'll see that the NSResponder has a TContextMenu which in turn has a NSMenuItem which holds the action responsible for compression. I didn't go any further, but from –  Miguel Mar 6 '12 at 10:18

5 Answers 5

up vote 7 down vote accepted

/System/Library/CoreServices/Archive Utility does have a preference setting for the archive format, but it only seems to control archives created by Archive Utility, not with the Finder. Plus, its format choices are Zip, regular (cpio archive), and compressed (gzipped cpio) -- tar and tgz are not on the list.

It's not quite what you're looking for, but Snow Leopard improved the "service" system to the point where it's actually useful for things like this. Run Automator (I know, but stick with me...), create a Service rather than a Workflow, set "Service receives selected" to "Files and Folders", then copy in the second action from the workflow 11 pointed you at, and save it under some reasonable name. Then select a file in the Finder, right-click, and look at the bottom of the contextual menu for the Service you just created. It'll also be available under the Action (gear) menu in the Finder toolbar, and under the Finder > Services menu. You can make a keyboard shortcut for it in System Preferences > Keyboard > Keyboard Shortcuts > Services (then find your service, click in the invisible right column, and type the shortcut you want).

share|improve this answer
    
As you say, "not quite" but I suspect this is as close as I'll get. :-) –  Carlton Gibson Jan 5 '10 at 8:50

Looking at /System/Library/CoreServices/Archive Utility.app it doesn't seem like there are any preferences for setting the archive format.

What I might suggest you do is to download and put CleanArchiver in your dock. Run it once and set bzip2 as the default, then whenever you want to compress something drag it to the icon in the dock instead of control clicking.

I guess it's not much different than doing the automator thing but it can be a handy tool as it can be set to automatically exclude stuff like .DS_Store files.

share|improve this answer

Look at:

/System/Library/CoreServices/Archive Utility.app/Contents/Resources

There is an Archives.PrefPane which will install itself if you click on that.

Unfortuntately it doesn't set much in terms of compression format or compression level. (seen in OSX 10.5 or 10.6)

share|improve this answer

Expanding on Gordon Davisson's answer, you might use a script like this in the Automator service:

set -e
[[ $# = 1 ]] && name=${1##*/} || name=untitled
base=${1%/*}
cd "$base"
i=2
[[ -e $name.tbz ]] && name="$name-$i"
while [[ -e $name.tbz ]]; do name="${name%??}-$((++i))"; done
COPYFILE_DISABLE= tar --exclude .DS_Store -cjf ./"$name".tbz -- "${@#"$base"/}"
open -R ./"$name".tbz

Setting COPYFILE_DISABLE tells tar to remove extended attributes and ACLs instead of creating ._ files. See this question.

tar archives often contain all files under a single directory, but if the script receives multiple files as input, it does not create a directory like that for the files.

share|improve this answer

move folder to desktop. right click on folder. in "FINDER" left click on file. Drop down menu opens. Select - Compress "file name".

share|improve this answer
    
This isn't about how to compress, but rather how to select the compression format. –  Daniel Beck Sep 26 '13 at 5:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.