Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Zip multiple files into individual archives via Automator' hint
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
Authored by: lar3ry on Aug 06, '07 09:57:16AM
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
for i in "$@"
do
    if [ -d "$i" ]
    then
        d=`dirname "$i"`
        b=`basename "$i"`
        (cd "$d"; /usr/bin/tar -cvjf "$b".tar.bz2 "$b" && rm -rf "$b")
    else
        /usr/bin/bzip2 -v9 "$i"
    fi
done


[ Reply to This | # ]
Zip multiple files into individual archives via Automator
Authored by: sstoy on Sep 25, '07 10:38:33AM

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.



[ Reply to This | # ]
Zip multiple files into individual archives via Automator
Authored by: nocomprendo on Aug 22, '12 07:16:22AM

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?



[ Reply to This | # ]