« Fun with Apple Remote Desktop 3 Scripting | Main | Sweet! »
This is one I wrote up today after getting tired of the way things normally decompress/dearchive in the Finder for me. It takes advantage of something I found via running "strings" on BOMArchiveHelper's executable. All it does is take a selected file or files in the Finder and dearchives them and any archives inside of them until there's no archives left to work on.
property fileAliasList : {} --property for a list of aliases to files
property theBOMArchiveHelperCommand : "/System/Library/CoreServices/BOMArchiveHelper.app/Contents/MacOS/BOMArchiveHelper dearchive-recursively " --the command to tell BOMArchiveHelper to recursively expand/dearchive things
property goodListLength : false --flag we use for error checking
tell application "Finder" --since we're selecting files in the Finder, we have to use that
set theFileList to the selection --get the selected file(s)
if length of theFileList > 0 then --if there's at least one selection, cool, otherwise nothing happens
set goodListLength to true --set the flag to true
repeat with x in theFileList --iterate through the list
set the end of fileAliasList to (x as alias) --get the location of each file in the list as an alias
end repeat --end of the repeat loop
else
set goodListLength to false --zero length list, no love
end if
end tell
if goodListLength then --if the error flag is true
repeat with x in fileAliasList --iterate the list of aliases
set theFilePath to POSIX path of x --get the posix path of an item, since BOMArchiveHelper won't play with aliases
do shell script theBOMArchiveHelperCommand & theFilePath --run our pre-built BOMArchiveHelper command with the posix path to the file
end repeat --end the repeat loop
end if
That's it. Pretty simple, but it makes my life a wee bit easier.
Technorati Tags: AppleScript, Mac OS X
