Geeks R Us

Archive for the 'Applescript' Category

Want to know which songs don’t have album art?

Friday, September 7th, 2007

Elizabeth likes her album art, but iTunes doesn’t let you sort based on the art, so here is an Applescript Application that will create a new playlist titled “Songs without Album Art”

Download

1.0.3

  1. Added dialog to inform user of what the application did and reveal the playlist in itunes automatically.

1.0.2

  1. Added an error list
  2. Exclude “TV Shows” as well as “Podcast” genres

Update: I turned the app into something a little nicer using Applescript Studio, but it is still ugly :) At least you get some feedback now.

Copy URL to clipboard Applescript

Friday, July 30th, 2004

As a blogger, I’ve often wanted the URL from the current website I am browsing put onto the clipboard in HTML format so I can quickly paste it into a blog entry. I wrote a simple Applescript to share.

To use:

  • If you don’t have the AppleScript menu installed, install it by running the Install Script Menu application in /Applications/Applescript/
  • In your home directory, open Library. If there is not a Scripts folder, create one. Inside the Scripts folder, if there is no Safari folder, create one.
  • Open Script Editor in /Applications and paste the script at the end of this entry. Save the file to ~/Library/Scripts/Safari/ as any name you like, such as Copy To Clip

That’s it. Now you can be in safari, choose your script from the Safari Applescript menu item and have your URL in HTML format!

The Script:

Safari

tell application "Safari"
    tell document 1
        set the clipboard to "<a HREF=\"" & my escapeURL(url) & "\" target=\"_blank\"></a>"
    end tell
end tell
on escapeURL(aURL)
    set newURL to ""
    set savedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {"&"}
    
    set aCount to count text item of aURL
    repeat with index from 1 to (aCount - 1)
        set newURL to newURL & (text item index of aURL) & "&"
    end repeat
    set newURL to newURL & last text item of aURL
    
    set AppleScript's text item delimiters to savedDelimiters
    return newURL
end escapeURL

Omniweb

tell application "OmniWeb"
    tell browser 1
        set the clipboard to "<a HREF=\"" & my escapeURL(address) & "\" target=\"_blank\"></a>"
    end tell
end tell
on escapeURL(aURL)
    set newURL to ""
    set savedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {"&"}
    
    set aCount to count text item of aURL
    repeat with index from 1 to (aCount - 1)
        set newURL to newURL & (text item index of aURL) & "&"
    end repeat
    set newURL to newURL & last text item of aURL
    
    set AppleScript's text item delimiters to savedDelimiters
    return newURL
end escapeURL

Categories