February 14 2018 - 9:31 am

Go to Music Library Shortcut

I’m often hopping around in iTunes among the “Library”, “For You”, “Browse”, “Radio” and “Store” tabs and likewise apt to be in a specific media library, like Podcasts or Movies. As such, it can be a minor pain to get back to my local Music library.

Okay, it’s only a couple of clicks. But it does elicit from me a small “arghh” burp from time to time.

So here’s a very simple script to which you can assign a keyboard shortcut that will display the Music library in the Library tab:

tell application "iTunes" to reveal (some playlist whose special kind is Music)

Save this in your home/Library/iTunes/Scripts/ folder and name it “Go to Music Library.scpt”. The script will appear in the iTunes Script menu. Then, open System Preferences and go to the Keyboard panel. Select “Shortcuts” and then “App Shortcuts” from the list on the left. Click the “+” button on the right side. In the drop down panel, select “iTunes” in the Application popup. Enter the name of the script, “Go to Music Library”, in the Menu Title text field. Enter your shortcut combination in the Keyboard Shortcut text field (I use Control-Command-H, where the “H” stands for “home”). Click the “Add” button and then close out of System Preferences. Thus, whenever you want to get back to your Music library, just hit the shortcut.

I’ve done something similar for my Internet Radio Station playlist.

January 13 2018 - 11:06 am

Segregate Shufflable Tracks

A Correspondent queries:

“Do you have a script that can create a playlist of songs if they have the “Skip when shuffling” attribute ticked in the info panel? The reason is because when I sync those songs to the iPhone that feature doesn’t sync along with it so they play regardless. The feature works on the Mac, just not on the iPhone.”

The shufflable property of a track does not have a corresponding Smart playlist criterion or Songs view column. So, looks like the only way to identify these tracks en masse is with AppleScript.

Interestingly, the shufflable property works somewhat backwards. If the “Skip when shuffling” checkbox is set (and a checkbox when checked has a “true” value) the corresponding shufflable property is set to false; that is, “not shufflable”. This might be the opposite of what you’d expect. For instance, when “Remember playback position” is set to true with a checkmark, its correponding bookmarkable property is set set to true (yes, allow this track to be bookmarked). Just kind of interesting. A little. But its important to keep in mind when you want to detect the correct (and not opposite) value.

Anyway, here’s a script that will copy any tracks in the Music library set to “skip when shuffling” to an existing playlist:

tell application "iTunes"

set targetPlaylist to playlist "Skip Shuffle Tracks"

set musicPlaylist to (some playlist whose special kind is Music)

set theTracks to every track of musicPlaylist whose shufflable is false

repeat with aTrack in theTracks

set db to database ID of aTrack


if not (exists (get some track of targetPlaylist whose database ID = db)) then error

on error


duplicate aTrack to targetPlaylist

end try

end try

end repeat

reveal targetPlaylist

end tell

Open this in Script Editor by clicking the little script icon. Save it named whatever you like as a Script Bundle in your ~/Library/iTunes/Scripts/ folder so that it will be listed in the iTunes Script menu. I have already created a playlist in iTunes named “Skip Shuffle Tracks” so make sure you do, too. if you want to use a playlist with a different name then you will have to hard-code that name in the script where I have used “Skip Shuffle Tracks”.

Whenever you run the script it will get a list of track references from the Music playlist where each has its shufflable set to false. It will iterate over this list and for each track it will first see if the track already exists in the target playlist; and if it does not the track will be copied to the playlist.

The second try block around the duplicate command ensures that if any track cannot be copied, such as a “dead” track, the script will skip it without erroring.

November 27 2017 - 10:40 am

Internet Radio Streams Playlist

I recently swapped receivers (or, I should say, amplifiers) in my office. I was using a decent mid-priced Sony receiver to power two zones of speakers: a set of Bose 301s and a “near-field” set of cheap desktop speakers and sub-woofer. I replaced it with an unused Onkyo amp I had purchased a few years ago. As a result of the switch, I no longer have a radio tuner in the configuration.

But, as it turns out, I don’t need one. I’m lucky enough to have all the local Boston-area stations I listen to available in the Internet Radio section of iTunes. I never paid much attention to them before since I had a receiver. This gives me some nice advantages:

  • Internet radio feeds seem to precede the part of the broadcast audio chain where the signal has the life processed out of it. I no longer have to tolerate crappy broadcast audio.
  • Almost all my music sources are available digitally in one application, iTunes. Pandora is the only audio service I use requiring another app, but I mostly listen to it on mobile.
  • I can AirPlay iTunes all over my house.

The only downside so far is that I can’t listen to live local play-by-play sports broadcasts because, for various “contractual obligations”, these broadcasts can’t be internet-‘casted.

One quibble I’ve always had with iTunes Internet Radio is that it’s not exactly easy to manage the stream tracks. Finding them in the Radio list can be a chore and sometimes stations will disappear and the re-appear with a different URL. There’s not much I can do about either of those issues.

But to make life a little easier, I have created a “__Radio” playlist to which I have dragged the stream URLs I regularly listen to. I’ve also create a little script to quickly pull up the __Radio playlist with a keyboard shortcut:

tell application "iTunes" to reveal playlist "__Radio"

I’ve assigned Option-Command-R as a keyboard shortcut to the script.

One other thing I’ve done is to store the URL address of each stream track in the __Radio playlist. I grab the address property of each URL track and then paste it into a text document for safe keeping:

Later, if necessary for any reason, I can open the address with something like this:

set theStream to ""

tell application "iTunes" to open location theStream

This will create a new URL track in a playlist called “Internet Songs”. I then drag the track to my __Radio playlist and usually delete the “Internet Songs” playlist, although keeping it around isn’t a bad idea either.

September 25 2017 - 9:05 am

Camelot Codes to Keys

For a brief time, back when I was radio DJ, a station I worked at experimented with using “key segues”, whereby a recorded sounder would transition from a song played in one key to a song in another. Thus: Song in C fades -> sounder transitions from C to A minor -> seg next Song in A minor.

It was horrendous.

Anyway. Since I was an Actual Musician (few and far between in radio), it was my job to assign the correct key for each song we played. Which essentially meant that I sat in a studio a couple of times a week with a CD player and a Casio keyboard and diddled around until I determined the key of each song we added that week.

Nowadays, a lot of DJs use the musical key of the tracks they play to create “harmonic mixes”; tracks are mixed or segued according to harmonic rules. Some DJs probably aren’t musically inclined either, so there is software and databases and such that can supply the key for their tracks. Then all they have to do is check the Camelot chart to see what might sound good.

(This, of course, is not perfect, since pitches can vary. Which is what made my old station’s experiments with key segues so cringey. We had CD players that could adjust for pitch, but nobody wanted to spend that much time on creating perfectly harmonic segues. But, whatever.)

I heard from a Correspondent who uses this system. He has the Camelot codes in his iTunes tracks’ Comments tags. These are codes that represent 24 musical keys and look like this: 1A, 2A, 3A…10B, 11B, 12B:

Courtesy of

He wants to convert the Camelot codes to the actual key. So here is a script that will do that: (more…)

September 5 2017 - 1:06 pm

Find Tracks with Multiple Artworks

This will corral all the tracks in the Music library that have more than one assigned artwork to a new playlist (whose name you supply; any existing playlist(s) with that name will be deleted beforehand):

tell application "iTunes"


set newPlaylistName to text returned of (display dialog ¬

"Enter a name for the playlist:" default answer "Multi-artwork tracks")

on error


end try


delete (every playlist whose name is newPlaylistName)

end try

set newPlaylist to (make new playlist with properties {name:newPlaylistName})

set musicLibrary to (get some playlist whose special kind is Music)

repeat with i from 1 to (index of last track of musicLibrary)


set aTrack to track i of musicLibrary

if (count of artworks of aTrack) > 1 then


duplicate aTrack to newPlaylist

end try

end if

end try

end repeat

display dialog "Done" buttons {"OK"} default button 1

end tell

Open this in Script Editor by clicking the little script icon. Save it named whatever you like as a Script Bundle in your ~/Library/iTunes/Scripts/ folder so that it will be listed in the iTunes Script menu. Launch the script and enter a name for the playlist; the default is “Multi-artwork tracks”; press OK.

March 28 2017 - 2:54 pm

Close a Playlist Window and Select Its Playlist

If it really drives you crazy that after closing a playlist window iTunes is compelled to put focus on the entire Music library, use the following script to close the frontmost playlist window and thereafter select the playlist it had contained in the main window:

tell application "iTunes"


set frontPlaylistWindow to front playlist window

set thePlaylist to view of frontPlaylistWindow

close frontPlaylistWindow

reveal thePlaylist

end try

end tell

Click on the little AppleScript icon above to open the script in Script Editor at your house—don’t copy the text in the browser.

Save the script as a Compiled “.scpt” with Script Editor named whatever you like in your [home]/Library/iTunes/Scripts/ folder so it can be launched from the iTunes Script menu. You may want to assign it a keyboard shortcut.

When run, it will get a reference to the front playlist window; if none is open, the script will fail silently. It will proceed to get a reference to the playlist contained by the playlist window, close the playlist window and finally select (reveal) the playlist.

March 22 2017 - 9:53 am

Playlist Windows

iTunes 12.6 has brought back Playlist windows and, judging from the reaction in my Twitter feed, they’re receiving a hearty welcome back. Couple of things, though: 1) The names of the open Playlist windows are not listed in the iTunes “Window” menu and 2) window names are blank for any Apple Music playlists opened as Playlist windows; they actually default to the name “iTunes” but this isn’t displayed either To be clear, the AppleScript name for the window of a subscription playlist is “iTunes” and not the name of the playlist. (Update: And now I’m not seeing this at all and all seems correct as far as names go; don’t know what I was seeing previously!)

I’m not so much concerned about the latter thing. But if you have a batch of Playlist windows open it can be an ordeal to select one you’d like to work in. This script will list all open Playlist windows in a choose from list panel so one can be chosen and then made frontmost:

tell application "iTunes"

if (count of playlist windows) < 2 then return

set windowList to playlist windows

set nameList to name of view of playlist windows


set chosenName to (choose from list nameList)

if chosenName is false then error

on error


end try

set chosenName to (chosenName as text)

repeat with i from 1 to (count of nameList)

if chosenName is item i of nameList then select item i of windowList

end repeat

end tell

Click on the little AppleScript icon above to open the script in Script Editor at your house—don’t copy the text in the browser.

Save the script as a compiled Script (“.scpt”) with Script Editor named whatever you like in your [home]/Library/iTunes/Scripts/ folder. When there are too many Playlist windows open and you can’t find any real estate to click on, launch the script to select the one you want brought to the front.

(Update: Of course, after I post this I immediately discovered that you can Command-tilde (~) through open Playlist windows.)

March 13 2017 - 3:26 pm

Preserve a Genius Shuffle Playlist

One of my favorite features of iTunes is Genius Shuffle. By pressing the Option key and Space Bar simultaneously, iTunes will construct a 25-track Genius-type playlist in Up Next around a “seed” track it chooses at random from your library. Typically, I’ll slap Option-Space Bar repeatedly until I get the type of songs I’m in the mood for. Sometimes though—because I have an itchy DJ finger—I’ll abandon the current set of tracks after a few songs and create a new different Genius Shuffle arrangement. But still I’d like to have been able to save the playlist I had abandoned because, at least for a while there, I really liked it. Well, you can do this with AppleScript.

When iTunes is playing Up Next like this the track references are available in current playlist. It is a simple matter to copy them to a new playlist. The script I’ve listed below asks for a name for the new playlist; I’ve set the default answer in the display dialog to “Genius Shuffle” and when I run the script I’ll keep that in the name, for example: “Rockin’ Blues – Genius Shuffle”, “70’s Funk – Genius Shuffle”, and so on.

tell application "iTunes"


if not (exists current playlist) then error

set opt to (display dialog “Enter a name for the new playlist:” default answer "Genius Shuffle")

set newP to (make new user playlist with properties {name:text returned of opt})

duplicate every track of current playlist to newP

reveal newP

on error


end try

end tell

Click on the little AppleScript icon above to open the script in Script Editor at your house—don’t copy the text in the browser.

Save the script as a Compiled “.scpt” with Script Editor named whatever you like in your [home]/Library/iTunes/Scripts/ folder.

One issue is that if any of the tracks in Up Next are “dead” tracks then the script will fail (a repeat loop could duplicate each track individually to filter dead tracks, but I wanted to keep this simple). On the other hand, I think iTunes will ignore dead tracks when it creates a Genius Shuffle playlist.

Also I would only run this after creating a Genius Shuffle playlist; it doesn’t make much sense to run it when anything else is playing.

February 26 2017 - 8:37 am

How to Blankety-Blank Blank

As you may have noticed, the last few versions of iTunes have been gradually “contextualizing” the interface. For example, the Info window will only display the kind-pertinent tags for a selected track. (Remember: it used to be that the Info window displayed the same configuration for any track; so that Music tracks had access to TV-kind tags, like Season and Episode ID, and so on.)

Despite this, when the iTunes browser window is in Songs view, non-contextual tags can still be displayed and tracks can still be sorted using them. This is because every track entry in the database has the same columns whether they are used for that kind of track or not. Thus, for example, Music tracks have “season” and “episode ID” track tags even though they are not used for Music tracks.

AppleScript can access these tags and a script of mine, Sort by Artwork Size, can store the dimensions of a track’s artwork (eg, “600×600”) to the Category or Episode ID tag. Tracks can then be sorted by their “artwork size” or those tags can be used when constructing Smart playlist criteria.

However, since these tags can’t be accessed very easily it is a chore to clear them if they are no longer required. So here’s a script that will blank a particular tag of all the selected tracks. In this case, it blanks the episode ID tag. For people who already know how to script such a thing, this will be easy as pie. But, if your skill level as a scripter is below Dabbler, you may want to use this as a template for your own blanking scripts: (more…)

August 15 2016 - 12:02 pm

Hassle-Free Playlist Description

One of the neat things that Apple added to iTunes not so long ago is the user-editable description that is available for regular Playlists (Smart, Folder, Genius and Master library playlists do not have this option) and is visible when the Playlist is in Playlist View. You can edit this description by clicking the Playlist’s “Edit Playlist” button. But when you do this, the iTunes interface changes: a column appears at the right edge of iTunes listing the current tracks in the playlist to which you can drag tracks. It also will change the (now center column) browser window to display the full Music library, which totally discombobulates me.

I do not always care for this when I just want to edit the Playlist’s description. I’d prefer to do so without shaking up the interface. This script will do it:

tell application "iTunes"


set thisPlaylist to (get view of front browser window)

tell thisPlaylist

if special kind is not none or smart or genius or shared then error

end tell

on error



end try

set defaultAnswer to (get thisPlaylist’s description)

if defaultAnswer is missing value then set defaultAnswer to “”

set newDescription to text returned of ¬

(display dialog "Enter the description text for the playlist" & return ¬

& thisPlaylist’s name default answer defaultAnswer)


set thisPlaylist’s description to newDescription

end try

end tell

Save this named whatever you like to your [home]/Library/iTunes/Scripts/ folder so that it will appear in the iTunes Script menu. Select a playlist and launch the script by selecting it from the Script menu. It will quit if the selected playlist is the wrong kind. It will display the current description for the playlist if it exists, otherwise the text field will be blank. Enter up to 255 characters, which is the most that the description can accept, and then click “OK”.

Give this a keyboard shortcut to maximize your quality of life.

Site contents © 2001 - 2018 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Legal.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
One who says "it cannot be done" should not interrupt one doing it.