dougscripts.com

AppleScript

December 5 2025 - 12:11 pm

Count Selected Tracks in Songs View?

Did I tell you that, evidently, the Music app doesn't show the number of selected tracks in the playlist's Status Bar when the playlist is in Songs View? Yup.

Wait, it doesn't show the Status Bar at all when the playlist is in Songs View. Luckily, no chains can keep me from writing this simple AppleScript:

tell application "Music"

try

set sel to selection

set numberOfSelected to (count of sel)

set s to " tracks"

if numberOfSelected is 1 then set s to " track"

display dialog ((numberOfSelected & s & " selected") as text)

end try

end tell

Comes out like this:

December 3 2025 - 12:33 am

Swap Light-Dark Modes

Just did some fiddlin' with the site to make it a little responsive to dark mode settings. So, to celebrate, here's a script to swap modes rather than jogging into System Settings whenever. I have it in the system-wide Scripts menu.

tell application "System Events"

tell appearance preferences

set dark mode to not dark mode

end tell

end tell

December 2 2025 - 3:14 pm

Folder Action to Add Files to Year/Month Folders

So now that I'm a Playlist XML exportin' maniac, I created a Folder Action to automatically file the exports to my "Playlist Exports" folder into Year/Month folders, according the date of save. Here it is. When a file is added to the folder the script is attached to, it moves it to a newly-created or existing Year/Month hierarchy:

on adding folder items to thisFolder after receiving theseItems

repeat with anItem in theseItems

tell me to processThis(anItem, thisFolder)

end repeat

end adding folder items to

to processThis(anItem, thisFolder)

set yearMonthPath to (do shell script "date '+%Y:%m_%b'") as text

-- Y=year, m=month number (for sorting), b=month abreviation. eg, 2025:06_Jun

try

set folderPath to (thisFolder & yearMonthPath) as text

tell application "Finder"

try

exists folder (folderPath as POSIX file as alias)

on error

do shell script "mkdir -p " & quoted form of POSIX path of (folderPath as text)

end try

move anItem to folder folderPath with replacing

end tell

end try

end processThis

November 25 2025 - 6:10 pm

Select None Lives

Did I say there was no "Select None" in Music app's Edit menu? Something had to be done.

tell application "Music"

tell (get view of front browser window)

try

reveal track 1 of it

reveal track 1 of it

end try

end tell

end tell

Run this when tracks are selected in a playlist and muscle memory has you going for Shift-Command-A. It first selects (reveal) the first track of the playlist, which clears any other selection. Then, (because of a bug?) the reveal command run a second time de-selects the first track, leaving no tracks selected.

November 25 2025 - 5:41 pm

Bug or Feature: No Shortcut to Delete a Playlist

Now one of the Things a Music app playlist doesn't do lately is obey a Delete keypress. Used to be a Delete or Command-Delete or something like that would delete the selected playlist. Magical. Nowadays, we have to right-click on it for the contextual menu and choose "Delete From Library"—which is wicked loaded title for a playlist contextual menu item lemma tell you just sayin'. So what a guy like me does is make a piddly little AppleScript:

tell application "Music"

tell (get view of front browser window)

if special kind of it is none then

try

delete it

end try

end if

end tell

end tell

Click the script icon above to open this script in your Script Editor, save it with the File Format of "Script" named "Delete Selected Playlist" in your ~/Library/Music/Scripts/ folder.

And then you just know I'm going to tell you to assign it a Shift-Command-D shortcut.

There's also no "Select None" in any Edit menus anywhere. But I digress.

October 21 2025 - 2:57 pm

What's Up with macOS 26 Tahoe and Music

For reasons unknown but guessable, it really doesn't appear like macOS 26 was ready for Prime Time. Nor many of its components. Including the Music and TV apps. And their AppleScripting capabilities.

But I've noticed that things are getting better as the macOS 26.1 Betas are released.

Several Correspondents have contacted me regarding problems with the reveal command. It is currently broken. The reveal command is used in an AppleScript Music script to select and highlight a track or a playlist. This borks, as we say, the features of several scripts.

However, in the latest macOS 26.1 Beta 4, reveal track works again but not reveal playlist. So...good-ish news?

Somewhat related—I think—is that set view of front browser window to playlist "Brit Blues" to select and highlight a playlist doesn't work either. But you can get view of front browser window.

The inconsistency suggests to me that "they just haven't gotten around to everything yet".

On another note, Regular Visitors may notice that I am updating many of the scripts. Believe it or not, its mostly UI stuff; windows in macOS 26 use larger corner radiuses which sort of squeezes the available real estate. Thus, stuff has to be re-aligned and so on. Otherwise my symmetry OCD will kill me.

July 9 2020 - 1:09 pm

Big Sur Public Beta Program

It is now time for my annual message about using apps and AppleScripts from this site with the newest macOS beta.

I have tested a few AppleScripts in the Developer Betas (there have been only two released so far) and they all appear to work as expected. However, until an app has been specifically updated to work with Big Sur, I suggest users be cautious about depending on AppleScripts running on the beta in mission-critical situations. I think this will be probably be more important once computers with ARM-powered silicon start shipping.

If you are on the betas and come across any anomalies, please let me know.

October 14 2019 - 10:43 am

Catalina Stuff

I've said previously that the AppleScript scripting definitions for the Music and TV apps are pretty much lifted from iTunes. However, there are differences.

For example, a script that targets composer of a TV track will fail. Because TV doesn't use the Composer tag. Or the Album Artist tag. Or the artist property. Instead of artist, TV has a director property. And a Music track doesn't understand show, season number or episode ID; a TV track won't grok movement or work properties.

Stuff like that makes it difficult to write one script that can work in both Music and TV without doubling-up some of the code. Or adding some extra conditional tests. I'm not complaining; it is what it is, to be simply trite about it.

* * * * * *

When analyzing the pasteboard in a drag operation from the Music app, the dragging pasteboard types include “com.apple.tv.metadata”, but one would expect there to be “com.apple.music.metadata” type in place of—if not in addition to—the “tv.metadata” type. ¯\_(ツ)_/¯

* * * * * *

There is definitely an Artwork Issue. Files that I have downloaded from the cloud do not contain image metadata, but the artwork is certainly downloaded into the Music database because I can see it throughout my library. I just don't see the artwork being transferred to the files at all. The files do not have "Get Info" artwork and the artwork does not appear in a Quick Look panel. However, artwork appears as expected for files that have always been local.

* * * * * *

Files downloaded from the cloud also do not contain purchaser metadata. Not sure what that's about.

* * * * * *

The previous two metadata issues may be related.

* * * * * *

I still don't know what's causing the Invalid parameter error people are seeing with launching scripts. As far as I can tell, the issue "goes away" after a short time.

Frankly, there's so much stuff going on when you first launch anything in Catalina (with permissions and warnings and threatening security dialogs and other whatnots) that it just may be a minor system glitch.

July 1 2019 - 9:01 pm

Doug's Check For All Updates v1.0

In case it isn't crystal clear: scripts written for iTunes will not work on macOS 10.15 and later. Since the iTunes application isn't available on the new OS, scripts that target it will fail. So, almost every script on the site will need to be re-written to work with the macOS Music and/or Apple TV apps that replace iTunes in macOS 10.15.

Oh, I'm keeping busy, all right. I would like to be posting updates for use with the Catalina betas. But there are currently some issues in the betas that have precluded me posting any Catalina-compatible scripts yet. I have no doubt that Apple will fix these minor glitches well before Catalina's offical release; I just don't know how soon. And even then, there will be a gradual rolling-out of script updates through the summer and fall.

To help users keep track of what scripts for which operating system have been updated and when, I've posted Doug's Check For All Updates. It's an applet that will survey your computer for all the scripts you have installed from dougscripts.com and generate a report listing which have been updated. This is unlike the "Doug's Check For Update" script, which can only check one script at a time.

Doug's Check For All Updates will work right now on any version of macOS 10.10 and later, including the macOS 10.15 betas.

May I suggest that it may be helpful to get some work done on your iTunes library with the latest tools now, before you update to Catalina and the new media apps. Your favorite script(s) may not be Catalina-ready by then.


A security aside: This is the first download I am posting that has been notarized by Apple, a requirement for third-party software if it is to be distributed outside the Mac App Store. As such, it is also the first download to be packaged as a .dmg (disk image file) without the .zip wrapper. The code-signing and notarization process in my workflow make it easier to process a disk image without the additional ZIP compression. All future new and updated scripts will be likewise packaged as DMGs.

April 21 2019 - 2:59 pm

Shortcuts and AppleScript on the Mac

Dr. Drang has posted some thoughts and questions about the future of automation on the Mac.

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