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

Categories:     Applescript, Mac Matters, Mac OS X Scripts
Posted by John C. Welch at 23:26 | Permalink



Comments

Warning for Notes users: The commenting system uses HTML.
I know this will be scary for some of you, especially Notes fans. However, open standards, rah-rah.
If you want to use less-than or greater-than signs, or other similar charachters that HTML reserves,
you'll simply have to learn to do it the HTML way. Luckily, HTML is kind of popular, no matter what
your re-educators have told you, and you can easily find help on the intertubes.
digital.forest Where Internet solutions grow

There, a PayPal Button.

 
Use this code for your Macworld tickets!
Family
The Artwork of Melissa Findley
Diane Francis @ the National Post Eric Francis @ the Calgary Sun

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