Archive for the 'AppleScript' Category

Automating the Amazon MP3 Downloader

Dec 02, 2007 in AppleScript

It’s Amazon day at, as I finally got around to trying Amazon MP3 and the Amazon MP3 Downloader app. At first, I wasn’t seeing the downloader launch automatically, then it dawned on me that said behavior was probably tied to Safari’s Open “safe” files after downloading preference.1

Between security concerns and general annoyance, I’d turned this feature off some time ago. In Amazon’s case, I actually wanted this functionality. A short AppleScript later and I had a working solution.

on adding folder items to this_folder after receiving added_items
    repeat with item_ in added_items
        tell application "Finder"

            if name extension of item_ is "amz" then
                open item_
            end if

        end tell
    end repeat
end adding folder items to

Save the script to ~/Library/Scripts/Folder Action Scripts/. In the Finder, navigate to your downloads folder, select Attach a Folder Action… from the contextual menu, and locate your newly saved script in the resulting file selection dialog. Now, whenever you download a new amz file from Amazon MP3, the Amazon MP3 Downloader will launch. Nothing earth-shattering, but I found that it improved the shopping experience.

Should you at some point activate the Open safe files… option in Safari, I’d recommend disabling this folder action. I haven’t done any testing, so I don’t know how well using both would or would not work.

  1. Yeah, putting “safe” in quotes sounds really reassuring. []

EagleFiler 1.2.6

Oct 24, 2007 in AppleScript, Mac

EagleFiler 1.2.6 has been released and it incorporates the work I’ve did on the MarsEdit capture script.1

Michael added support for setting the source URL to the post’s permalink. Among other things, this activates the Open Source URL command in the Record menu.

If you’ve got my capture script installed in EagleFiler’s Application Support folder, you won’t see this new functionality — EagleFilers gives precedence to user-installed scripts over its own bundled scripts. If you’re just using the capture script as I originally posted it, you can delete my script. You’ll gain the source URL functionality without losing anything.

If you’ve customize the capture script to better suit your workflow, you can apply Michael’s change to add support for setting the source URL. Just replace this line:

return {{|path|:tempPath, |title|:theTitle, tags:theTags, |deleteWhenDone|:true, |note|:theNote}}

with the following (sorry about the long lines):

if thePermalink is not "" then
    return {{|path|:tempPath, |title|:theTitle, tags:theTags, |deleteWhenDone|:true, |note|:theNote, |sourceURL|:thePermalink}}
    return {{|path|:tempPath, |title|:theTitle, tags:theTags, |deleteWhenDone|:true, |note|:theNote}}
end if

While checking out the change notes for the updated EagleFiler, I noticed the following line:

You can now modify capture scripts while EagleFiler is open without having to relaunch for it to notice the changes.

Thank you. Thank You! ThanksYouThankYouThankYouThankYou!

(Can you tell I hit this issue while writing the original capture script?)

Oh, did I say thank you?

I’ve been playing around with an updated capture script on my own system, but I’ve been hesitant to post it because it relies on components that are part of a stock Tiger installation. I want to check out whether the situation is any different when running Leopard. I’m not sure when I’ll get around to upgrading, though.

  1. The new all capture scripts, all the time. []

EagleFiler and MarsEdit 1.2

Oct 23, 2007 in AppleScript, Mac

If you’ve tried using using my EagleFiler Capture Script with MarsEdit 1.x, you’ve probably noticed that it doesn’t work — EagleFiler claims it doesn’t support capturing from MarsEdit.

The solution is to rename the capture script from to com.ranchero.MarsEdit.applescript. Once you do this, EagleFiler will recognize the older version of MarsEdit.

You’ll also need to comment out or delete the two lines in the script that begin with if theVersion ≥ 2. As the line implies, the functionality is only present in the newer version of MarsEdit. I had assumed that including the conditional statement would allow the script to run with older versions of MarsEdit, but it would appear that I was wrong.

MarsEdit to EagleFiler

Sep 19, 2007 in AppleScript, Mac

Update (11/24/07): EagleFiler 1.2.6 now includes built-in support for capturing from MarsEdit that expands on this capture script. That capture script is located inside the EagleFiler application, in the Contents/Resources/Capture Scripts/ folder. More information is available here.

With MarsEdit 2.0‘s release, I’ve decided to re-evaluate my post management scheme. Previously, I created my posts in BBEdit, then moved them over MarsEdit via an AppleScript. I did this because I wanted to have copies of my posts archived on my hard drive and not lost whenever I refreshed my weblog in MarsEdit. A downside to this approach is that I end up underusing MarsEdit’s Draft’s functionality — I’d either keep the BBEdit window open the whole time I was working on a post or I’d save the post to my Posting directory and have to remember finish editing it at a later date.

My app tool-chain has shifted a bit over the last 3 years, so I now have a few more options at my disposal. One of those is EagleFiler. My new workflow is to compose and post in MarsEdit, then move the completed post of to Eagle Filer. To facilitate this, I’ve written an EagleFiler capture script for MarsEdit — to archive my post, I simply need to hit F1.

The script’s a bit long to include here, so I’m just going to post it for download.

Download MarsEdit Capture Script

To use this script, save it to ~/Library/Application Support/EagleFiler/Capture Scripts/, creating the last folder if necessary.

There are a few notes about what information is available for capture. First, you can’t capture a draft from the main MarsEdit window, only from the individual post window. Second, drafts which you have saved locally will have a value for date published. I believe this is the date the draft was first saved. Third, posts captured from the post window will not have a permalink value. Hopefully, future updates to MarsEdit will allow me to rectify at least a few of these.

There’s certainly room for some individualization in this script. Though I’ve stripped out the modification for public usage, my personal copy of this script adds some custom tags to each posting and sets BBEdit as the file creator. Another modification I’ve seen is adding the category information to the text of the posting. Additionally, you could add support for creating EagleFiler tags out of post keywords in addition/in place of post categories. Since WordPress doesn’t support keywords, I didn’t implement this.

If you do edit the capture script after installing it, you’ll need to restart EagleFiler so the application will see the changes.

I wrote and tested this script for use with WordPress blog. As far as other blogging packages are concerned, the script appears not to fail, though I can’t guarantee it’ll actually work.