Friday Random Ten Applescript

Friday Random Ten is a common blog posting… on Fridays people post ten random tracks from iTunes or I guess any other music program. For Macintosh users, I’ve made an easier way to make such blog postings. Just select tracks and this Applescript will put HTML for an ordered list in the clipboard which you can paste into your blog posting.

tell application "iTunes"

set maxCount to count items of selection
set loopCount to 1
set quo to "<ol>" & return
repeat until (loopCount > maxCount) or (loopCount > 10)

    if (genre of item loopCount of selection is "Classical") or (genre of item loopCount of selection is "Opera") then
        set quo to quo & "<li><b>" & (composer of item loopCount of selection) & "</b> -" & space
        set quo to quo & "<i>" & (album of item loopCount of selection) & "</i> -" & space
        set quo to quo & (name of item loopCount of selection) & "-" & space
        set quo to quo & (artist of item loopCount of selection) & "</li>" & return
    else
        set quo to quo & "<li><b>" & (artist of item loopCount of selection) & "</b>-" & space
        set quo to quo & "<i>" & (name of item loopCount of selection) & "</i>-" & space
        set quo to quo & (album of item loopCount of selection) & "</li>" & return

    end if

    set loopCount to loopCount + 1
end repeat
set quo to quo & "</ol>"

end tell

set the clipboard to quo as text

display dialog ((loopCount - 1) as string) & " tracks copied to clipboard as HTML ordered list"

You can also download the script. It must ultimately go in ~/Library/iTunes/Scripts/

Other posts

Leave a Reply

Bad Behavior has blocked 63 access attempts in the last 7 days.