Creating gzipped tarballs from Mac Finder
May. 24th, 2013 03:46 pmWorking on open source projects usually requires one to submit patch files and gzipped tarballs to one's compatriots. This isn't a big deal on most UNIX (including Linux) machines. On Windows one can do this with 7Zip, excepting that newlines in Windows are usually represented by \r\n instead of \n. On Macs, one can do this on command line, but it's more Mac-like to do it in Finder.
There are instructions here for setting up just such a service in Finder. Unfortunately it only tells one how to create tarballs, not how to create gzipped tarballs. It also zips normally hidden Mac copy files along with the expected files, which can leave one's compatriots with a mess.
You can fix both of these messes by using the below script instead of the one provided by Mr Miller. All I've done here is change the last line in accordance with this hint. Hope it's useful.
(I know, I know, the code isn't indented. Unfortunately the only way to really ensure indentation in LiveJournal is to play with CSS, and my CSS-fu is weak. You'll have to make it pretty yourself.)
There are instructions here for setting up just such a service in Finder. Unfortunately it only tells one how to create tarballs, not how to create gzipped tarballs. It also zips normally hidden Mac copy files along with the expected files, which can leave one's compatriots with a mess.
You can fix both of these messes by using the below script instead of the one provided by Mr Miller. All I've done here is change the last line in accordance with this hint. Hope it's useful.
(I know, I know, the code isn't indented. Unfortunately the only way to really ensure indentation in LiveJournal is to play with CSS, and my CSS-fu is weak. You'll have to make it pretty yourself.)
Tarfile="$1.tar.gz"count=1cd "${@%/*}"if [ $# -eq 1 ]; thenwhile [ -e "$Tarfile" ]dolet count++Tarfile="$1 $count.tar"doneelseTarfile="Archive.tar"while [ -e "$Tarfile" ]dolet count++Tarfile="Archive $count.tar"donefiCOPYFILE_DISABLE=true /usr/bin/tar -chzf "$Tarfile" "${@##*/}"