dougscripts.com

February 7 '16 - 12:44 pm
UPDATED: Album Rating Reset v2.0

Album Rating Reset will allow you to set the Album Rating and/or Album Loved for the albums of the selected tracks or the albums associated with the tracks in a selected playlist.

Album Rating Reset

I had pretty much given up on Album Ratings as just more Songs View clutter. I’d hidden the Album Rating column in Songs View. When there’s no avoiding it in Album Views I prefer the computed Album Rating that averages the album’s track ratings. But now that I use Apple Music fairly regularly, the Loved settings for tracks, albums and playlists in my library actually work pretty well with shaping Apple Music recommendations.

So I updated Album Rating Reset from a version last updated in 2007 to include Album Loved. The older version would only work on one track a time. But this version works on the selected tracks’ albums or the albums associated with the tracks in a selected playlist. I don’t think there is a way in iTunes to apply an Album Rating or Album Love to multiple albums at a time except while in Albums View.

Album Rating Reset

More information and download is on this page.

February 4 '16 - 1:39 pm
UPDATED: Show In Playlists v1.4

Show In Playlists is a stay-open applet that monitors iTunes and detects when library tracks have been selected and then displays a heirarchical list of the playlists containing the selected track(s) (emulating iTunes’ “Show In Playlist”).

Show In Playlists

It can also be set to monitor only playing tracks (excepting “For You” and “New” Apple Music, alas). Clicking a playlist in the list chooses it in iTunes, and if a single track had been selected then it will be selected in the chosen playlist. Additionally, the monitoring routine can be toggled off temporarily so that the current list of playlists remains fixed yet still selectable.

This latest version fixes a problem resolving old and new-style iTunes Library.xml data which may have caused playlists to display erroneously.

Show In Playlists is free to use for ten days and $1.99 thereafter. This is a free update for registered users. More information and download is on this page.

January 23 '16 - 12:10 pm
Delete Other Artwork

iTunes is able to accommodate more than one image for a track entry’s artwork. What hasn’t always been obvious is that the first artwork in an array of artworks in a track is the “display” artwork. Any additional artwork in the artworks array are spares. Modern versions of the iTunes Get Info Artwork panel now label images as “Album Artwork” and “Other Artwork”.

Some people think that these “Other Artwork” have to go.

It is a simple matter to simply remove the other artwork from a track entry with an AppleScript. Here’s one now that goes through each track in a selection and repeats through its artworks (if there’s more than one artwork), removing the last artwork until there is only the first one left:

tell application “iTunes”

set selectedTracks to selection of front browser window

repeat with i from 1 to (count of selectedTracks)

set thisTrack to item i of selectedTracks

tell thisTrack

try

if (count of its artworks) > 1 then

repeat until ((count of its artworks) is 1)

delete its last artwork

end repeat

end if

end try

end tell

end repeat

end tell

Click the script icon above to download this script to Script Editor at your house and click “New Script” to allow it to open. Save it named whatever you like in your ~/Library/iTunes/Scripts/ folder (or wherever you put them). Select some tracks in iTunes and launch the script.

There’s always the kid in the front who wants to know why you don’t make a script like this that just works on the entire library. Well: iTunes can be kind of touchy when AppleScripting a large amount of artwork stuff. It may “go modal” as it updates its database and under such circumstances may block an AppleScript from continuing its operation. So I purposely used the selection object so that the script can be used piecemeal on a small batch of tracks at a time. Additionally, you might want to eyeball the “Other Artworks” of a track before you start blindly mowing them all down; in which case having to select the tracks manually compels you to be in control.

The routines are in a try block to skip over errors because of what I mentioned above about modality and also in case there’s some image gunk in there that causes trouble. Because images downloaded from the internet that you use as album artwork are always pristine, right?

January 21 '16 - 7:52 am
EPPC Bug? Probably Not

Not long ago, a user reported an issue using the EPPC protocol to access AirPlay properties of iTunes on a remote machine. To keep a long story short, it doesn’t appear to be a bug. The user neglected to incorporate a “using terms from” block. I should have known at the time that this was a likely omission. This is an example how the code should be implemented:

tell application “iTunes” of machine “eppc://user:password@Remote-Machine.local”

using terms from application “iTunes”

set apDevices to (get name of every AirPlay device whose available is true)

end using terms from

end tell

January 11 '16 - 6:15 am
Playlist Time to Playlist Name

Here’s a simple script that was inspired by a question Kirk got asked in his Ask the Tunes Guy column in Macworld last week. A user lamented that the playlist length (that is, its total time) is not available in the Music app on iOS. Kirk recommended adding this information to the playlist name in iTunes and then re-syncing. A good solution but kind of a chore. This script will do the renaming part for you.

Just select a playlist in iTunes and launch the script. It will display a confirmation dialog and then rename the playlist by appending the time length to its current name:

tell application “iTunes”

try

set thisPlaylist to view of front browser window

if special kind of thisPlaylist is none then

set newName to (my fixName(thisPlaylist’s name) & ” | ” & thisPlaylist’s time) as text

— confirm

try

display dialog “Rename selected playlist to:” & return & return & newName

on error

return

end try

tell thisPlaylist to set name to newName

else

error

end if

on error m number n

try

display dialog “Can’t change the selected playlist’s name.” buttons {“OK”}

end try

return

end try

end tell

to fixName(n)

if n does not contain “|” then return n

return text 1 thru ((offset of “|” in n) – 2) of n

end fixName

Couple of things to note: only user-created scripts (plain and Smart) can be affected. Also the script uses the “pipe” character to separate the actual name with the appended data. When you run the script again on a playlist that has previously been affected by the script, it uses the “|” as a marker to erase the appended text; thus, the playlist name can be updated if the contents changes at a later date. So, if you happen to already use “|” in your playlist names you may have a problem. You can edit the script in Script Editor to change each of the occurrences of “|” to some other text character that you aren’t likely to use.

January 9 '16 - 6:30 am
Fifteen Years On

Happy birthday, iTunes!

iTunes v1.0 was announced and released on January 9, 2001. I don’t think a day has gone by since that date that I haven’t used iTunes. Seriously. It’s probably the most regularly used app on any of my machines. Love it or hate it, for better or worse, you have to acknowledge that iTunes has had a huge impact on how music is consumed. Amazing. (Kirk McElhearn has written a fifteenth anniversary tribute that covers the milestones.)

And, lest they be forgot, here’s a shout out to the developers of SoundJam MP, the jukebox app that Apple bought and re-christened as iTunes: Bill Kincaid, Jeff Robbin and—most especially as far as I’m concened—Dave Heller, who incorporated AppleScript into SoundJam and then iTunes.

December 30 '15 - 7:48 am
EPPC and AirPlay Bug?

A Correspondent alerted me to an issue he is seeing, and that I can verify, using the EPPC protocol to access the AirPlay device property via iTunes on a remote machine. For example, with Remote Apple Events enabled on a remote machine, a script like this—that up until recently worked—will fail:

tell application “iTunes” of machine “eppc://user:password@Remote-Machine.local”

set apDevices to (get name of every AirPlay device)

end tell

In this example, you would expect to get a list of the names of the AirPlay devices available on the remote machine. But instead, the script trips up on the word “AirPlay” with the error “Expected class name but found identifier”. “AirPlay device” is a class name. Other conventional iTunes/Remote Apple Events routines work as expected.

Our Correspondent reports that this sort of script worked happily in the past; sounds like he uses it to control iTunes like a server on the remote machine. There have been EPPC-related bugs in the past that were introduced with Security Updates so I’m hoping this is one of those sorts of things and not a deliberate “security feature”. File a bug if you can.

December 11 '15 - 4:27 pm
iTunes 12.3.2 Available

Apple has updated iTunes to 12.3.2 with improvements to browsing works, performers and composers for Classical tracks in Apple Music. More as it develops.

December 3 '15 - 3:57 pm
Track Numbers in the Thousands

A Correspondent who uses my applet Multi-Item Edit to enter five-digit track numbers has reported that iTunes now formats these numbers with a comma; for example, 16789 becomes 16,789. iTunes itself will only allow three digits to be entered in the Get Info track number field, so it is unlikely that most users would ever encounter this. According to my Correspondent, this is a relatively recent iTunes behavior.

It’s not like track numbers are “counting numbers”. They’re more like digits. Is that the arithmetical name for that sort of thing?

Multi-Item Edit is able to enter more than three digits because the AppleScript track number property accepts integers and I guess nobody ever thought of limiting the input to less than 1000.

Interestingly, track numbers used to only go to 99 because that was the Red Book-limited number of audio tracks allowed on a CD. Thus the original ID3 Tag spec only allowed two digits for track numbers. Because, the thinking at the time went, why would there ever be a need for more? Although I recall that you could “fake” more tracks using CD track indexes. I’m not sure what the spec is now since there’s no such thing as audio files anymore. (Just kidding. Been reading too many tech articles on streaming lately.)

I’m going to file the comma issue as a bug just to be ticky-tacky about it, but—also interestingly—the episode number tag does not use comma formatting and it also only accepts integers, at least as far as AppleScript is concerned (you can see the track row at the top of this screenshot):

As I mentioned, it’s unlikely most people would ever notice this, but you might if you were taking advantage of this greater-than-999 kludge with AppleScript.

November 24 '15 - 10:22 am
NEW: Doug’s Check For Update

While some applets and all apps from this site have a menu command to “Check for Update…”, many AppleScripts do not. To make it easier to check if a script you downloaded at one time or another has a newer version available, use Doug’s Check For Update. Just drop an AppleScript file on it (or launch it and use an Open Panel to navigate to a specific script) and it will check the website for the latest version of that script:

Doug's Check For Update

Sure, it’d be great if I could include a Sparkle-like mechanism to automatically check and install updates—as my apps do. But the code required to do so would just add too much overhead to a—very likely—simple AppleScript.

More information and download is here.

 
Site contents © 2001 - 2016 (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.