downloaded 21m 27s ago
For Music Remove iTunes tracks disassociated from files
downloaded 23m 27s ago
For Music Sort purchased tracks into discrete playlists by name or Apple ID
downloaded 29m 5s ago
For Music Batch-change/clear the Album Rating for albums of selected tracks
downloaded 31m 46s ago
Check all scripts from dougscripts.com installed on your computer for updates
downloaded 42m 30s ago
For Music/TV Title Cap various track tags, featuring editable exceptions lists
downloaded 48m 3s ago
For Music Perform search-and-replace on text in your choice of tags
Download hundreds (542 and counting) of AppleScripts for Apple's Media Apps that will help make managing your digital music and video collection easier and more fun!
AppleScript is a simple Macintosh-only programming language that can control and automate actions on your Mac. AppleScript is already available on your computer as part of the macOS and many popular applications can be automated using AppleScript scripts. Scripts written for Apple's Music, TV and iTunes apps can manage files and track information, create playlists, interact with other applications, perform innovative tasks, and handle many kinds of chores with accuracy and precision which otherwise would be repetitive, laborious, and/or time-consuming.
Cool! Where Do I Start?
Start browsing the site by using the scripts ↓ Menu link above. AppleScripts are gathered into these general Categories:
- Managing Tracks
- Managing Track Info
- Managing Artwork
- Managing Playlists
- Controlling iTunes
- Exporting Info
Or use the search box at the top of every page to try and find something specific.
Not sure how to install AppleScripts? Here's a Download/Installation FAQ.
Check back often or follow me on Twitter @dougscripts, my YouTube channel, or subscribe to my RSS blog feed and 30 Most Recent Scripts RSS feed to stay notified about new and updated scripts and info.
Coverscope is an applet that helps manage track and file artwork. It will display both the track entry artwork and the artwork metadata from the track's file:
If one or the other is missing, the extant image data can be applied or embedded to the other. If both artworks are missing, an image from the clipboard can be pasted or an image file dragged to the Track entry artwork well to apply and embed it to the selected track.
Additionally, the Track entry artwork can be copied to the clipboard or exported as a file.
Coverscope is free to try in Demo Mode. In Demo Mode, any combination of features can be used up to five times per launch. A registration code to remove this restriction is US$2.99. More information and download is here.
I just updated the OS and the Music app. Happily, it appears the artwork issues are fixed and AppleScript can access the artwork data of a track (unless it's a file downloaded into the "Apple Music" folder). Additionally, playlist drags into and out of Folder playlists work as expected; it's just as tricky as it ever was in iTunes, but at least it's a sure thing.
There is still an AppleScript bug whereby delete playlist leaves a "ghost" playlist in the Sidebar until the next Music re-start. I have a few scripts in the pipe that rely on being able to delete playlists properly so this will need to be fixed before they can get posted.
Also, the reveal playlist command fails to scroll the selected playlist into view if it is not already in the Sidebar's view.
Otherwise, seems pretty solid.
Busy busy busy! So much so that the email newsletter I've been aiming to release still ain't got out and I have yet to even look at my App Store apps. The latter will not run in Catalina. But here's a batch of scripts that do:
In case you haven't noticed: If you have downloaded a file from the cloud or have had Music provide artwork, the image data does not get written to the track's file, even though you will see artwork for a track throughout Music.
Additionally, there's no way for an AppleScript to access the artworks of these kinds of tracks.
If the files of your tracks had image metadata before updating to Catalina, then you probably don't have any artwork problems with those.
My specific issue is that files on machine A that have custom artwork I applied to them and that sync via Cloud Music Library do not have the custom artwork when I download them to machine B. Instead, they have whatever artwork Apple has assigned for the album.
I had hoped that there might be an AppleScript trick to workaround this, but as I mentioned above, AppleScript wlll error when attempting access the artwork data or raw data properties of these tracks:
tell application "Music"
set theTrack to item 1 of selection
count artworks of theTrack
--> 1 , accurately detects 1 artwork
get raw data of artwork 1 of theTrack
--> error number -1728
--> error "Music got an error: Can’t get raw data."
You can test this yourself, either with the script or by trying to copy the small artwork image displayed in the top left corner of a track's Show Info window and pasting it somewhere. It won't.
[UPDATE 10.29.19: Hey! Apple fixed many of these issues in the macOS 10.15.1 and Music v1.0.1 updates.]
A couple of years ago, Apple added a new option to iTunes Preferences:
This, and the fact that the support doc for this feature referred to the "Legacy library XML", was Apple's way of telling developers that the XML was going to go away.
The iTunes Library.xml file is a condensed version of the iTunes Library database periodically exported as a property-list-like text file by iTunes itself, generally whenever a change occurred to the database: you played or tagged a track, created or deleted a playlist, and so on. It can easily be imported and parsed quickly by an application, even an AppleScript. You've probably used an AppleScript from this site that asked you to turn the "Share" option on, right?
A year or two before the "Share" option was added, Apple introduced the ITLibrary framework, which is an API that developers can use to get info about the iTunes library (and now the Music and TV apps) instead of having to use the iTunes Library.xml file.
So anyway, the XML has finally gone away, effectively, since it is no longer automatically exported.
I've been trying to incorporate the ITLibrary framework into my projects whenever I can, especially for apps that need to display lots of tracks or playlists (like Media Folder Files Not Added).
But ITLibrary was apparently last updated for macOS 10.13. And now that iTunes has been split out into the media apps, it's usefulness over the XML file has not been improved.
(And please. Don't let me hear anyone suggest some groovy way of exporting the XML automatically. Forget about the XML. Unless it's for backups or something.)
- ITLibrary does not know about Work and Movement tags.
- ITLibrary does not know the difference between playlists in the Music app and playlists in the TV app. You can ask for discrete music tracks or TV tracks or movie tracks, but not discrete playlists from either app.
- ITLibrary does not know what a subscription playlist is. It's an Apple Music playlist you have added to your library. ITLibrary sees it as a Regular playlist.
- Ditto Loved and Disliked for tracks
- Ditto Loved and Disliked for playlists
- ITLibrary does not distinguish among types of cloud tracks (uploaded, matched, duplicate, etc)
- ITLibrary does not provide a Track ID which is used to correlate the tracks in a playlist to their library entries and vice versa.
And I'm sure I've run into other minor impediments. Wait, bonus gripe: converting decimal persistent IDs to hexidecimal. (Strangely, the ITLibrary required you codesign your app in order to use it, but I'm not seeing this prohibition in Catalina. Am I missing something?)
It would be great if someone over there could give us a dusted up version of ITLibrary. Meanwhile, there's still AppleScript.
This script will create a copy of the selected playlist or folder playlist with its tracks' play order shuffled--unlike Music's Shuffle modes which do not display the shuffled order of tracks.
Set the Plays of the selected tracks to a user-entered value (they will all be set to the same value). If this value is 0 then the Last Played date of each track will be erased. (The Music app has the ability to "Reset" Plays to 0 from a track's Show Info window.)
For macOS 10.15 Catalina and later only. Add or subtract a user-entered number from the current Plays of each selected track. If the resulting Plays is 0 then the track's Last Played date will be erased--as if it had never been played.
For macOS 10.15 Catalina and later. Set Last Played/Last Skipped date of selected tracks to a new date, with option to increase or decrease Plays/Skips, or set to no date and no Plays/Skips.
This script will reset the Plays, Last Played, Skips, Last Skipped, Remember Playback Position and Played properties of the selected tracks to default “never played” values. Music's own "Reset" command in a track's Info window may not be as thorough.
This latest version makes accommodations for macOS 10.15 Catalina and the Music app.