« Fun with Apple Remote Desktop 3 Scripting | Main | Sweet! »

Stupid AppleScript Tricks

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: ,

Posted by John C. Welch at 23:26 | Permalink


Comments

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?


digital.forest Where Internet solutions grow

 
Apple Amazon Links
Apple Mac OS X Server 10.5 [Unlimited]

Apple Mac OS X Server 10.5 [10-Client]

Apple Mac OS X 10.5 Leopard

Apple Mac OS X 10.5 Leopard [5-User Family Pack]

Amazon Book Links
Legacy of Ashes: The History of the CIA

The Donnas: Bitchin'

Wizards at War (The Young Wizards, Book 8)

The Demon's Sermon on the Martial Arts

The Collected Stories of Arthur C. Clarke

JavaScript and Ajax for the Web, Sixth Edition

Awakening Warrior: Revolution in the Ethics of Warfare

FOB Links

Mac Web Writers

Techie Links

Review Victims