(* Freeware AppleScript from WhatsMyIP.org © 2017 Check out our other scripts! @ http://www.whatsmyip.org/lib/applescripts/ Compress Folder makes a compressed tar archive of a folder. It can use bzip2 or gzip compression. You can drop a folder on to the script or double-click the script. *) on run set x to choose folder with prompt "Please choose a folder to compress..." open x end run on open x set droptype to folder of (info for x) if droptype then compress_folder(x) else compress_file(x) end if end open on compress_folder(x) set zipkind to button returned of (display dialog "Would you like to bzip2 or gzip the folder?" buttons {"bzip2", "gzip", "Cancel"} default button 2 with icon note) if zipkind = "bzip2" then set flags to "-cvjf" set suffix to ".tbz" end if if zipkind = "gzip" then set flags to "-cvzf" set suffix to ".tgz" end if set foldername to name of (info for x) set pathofx to POSIX path of x set dirname to do shell script "dirname '" & pathofx & "'" set command to "cd '" & dirname & "'; tar " & flags & " '" & foldername & suffix & "' '" & foldername & "'" do shell script command display dialog "The folder '" & foldername & "' has been compressed." buttons "OK" default button 1 with icon note end compress_folder on compress_file(x) set zipkind to button returned of (display dialog "Would you like to bzip2 or gzip the file?" buttons {"bzip2", "gzip", "Cancel"} default button 2 with icon note) if zipkind = "bzip2" then set cmd to "bzip2" end if if zipkind = "gzip" then set cmd to "gzip" end if set filename to name of (info for x) set pathofx to POSIX path of x do shell script cmd & " '" & pathofx & "'" display dialog "The file '" & filename & "' has been compressed." buttons "OK" default button 1 with icon note end compress_file