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


Click here to return to the 'applescript tool to make zip/bzip archives' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
applescript tool to make zip/bzip archives
Authored by: SOX on Dec 20, '04 01:37:32PM
the following applescript makes tar-bzip2 archives out of any selected folder. put it in your finder tool bar or add it to the action menu. select a folder and then click the tool.

you can modify it to make zip files too of course. But zip and bzip are not natively aware of HFS file resource forks/meta data.

tell application "Finder"
  try
    activate
    set frontWin to folder of front window as string
    set frontWinPath to (get POSIX path of frontWin)
    do shell script "perl -we '$x = \"" & frontWinPath &
      "\"; die \"aborting: can not parse \n$x\n\" unless 
      $x =~ m(^(.*/)([^/]*)/$);$a = quotemeta($x);$d = 
      quotemeta($1);$t= quotemeta($2);$y = $t.\".tbz2\";die 
      \"aborting: source is not a folder\n$x\n\" unless  
      -d $1 and -d $x;  die \"aborting:  target exists\n 
      $y\n\" if -f \"$d/$y\";$command = \"cd  $a/.. && 
      tar --bzip2 -cf $y $t\"; exec $command '"
    on error error_message
      beep
    display dialog error_message buttons ¬
     {"OK"} default button 1
  end try
  activate
end tell
end run
IMPORTANT NOTE FROM THE EDITOR: I have seriously modified the above script so that it will display in a much narrower fashion. If you're using this script, you'll need to modify the do shell script... line. Remove every line break, replacing each with a single space. The end of the script is the line that starts with tar --bzip2....

[ Reply to This | # ]