dougscripts.com

June 26 2019 - 8:20 am

Targeting Two Media Apps

If you've got scripts you've written for iTunes, one of the first things you'll realise in Catalina is that instead of having one media app you have two. Sure, this seems self evident. Until you try converting your iTunes scripts to Music and/or Apple TV scripts.

Let's say you have a script that gets the name of the selected playlist. No matter what kind of playlist you selected in iTunes, this script reliably returned its name. Thus, it would work with a playlist containing strictly music tracks or one with only video tracks. But that was in iTunes. Now, music tracks are in Music and video tracks are in Apple TV.

You could write two scripts, one for Music and one for Apple TV. Or you could write a script that includes routines that can target both, doubling the size of your script.

Or you could use a simple trick to target one or the other app depending on where the script is installed. I always recommend putting your scripts in the app's "Scripts" folder. It's just a matter of getting the "path to me" which will return the file path of the script.

Then, you haul out the good ol' "using terms from". Throw it all together like this to make a script swing:

set myPath to (path to me) as text

set mediaAppName to "Music"

if (myPath contains ":Apple TV:") then

set mediaAppName to "TV"

end if

using terms from application "Music"

tell application mediaAppName

-- do your things in the app

set playlistName to (get name of view of front browser window)

end tell

end using terms from

Using the script's file path location—which will be something like Macintosh SSD:Users:username:Library:Music:Scripts:Name of Script.scpt or Macintosh SSD:Users:username:Library:Apple TV:Scripts:Name of Script.scpt—we can determine which app to target. This name is saved to the mediaAppName variable. (This trick will also work if you store scripts in the local Library folder or in the Library/Scripts/Applications/Music/ or Library/Scripts/Applications/Apple TV/ folders since they all contain the app name in the file path.)

Next, a using terms from block is hardcoded to target "Music", followed by the tell block for mediaAppName. This allows the script to compile while you're working on it in Script Editor. Since both the Music and Apple TV scripting goodness are virtually identical, you can indeed "use terms from" Music to automate either app.

Now instead of making two scripts, you can put a copy of one script in both Scripts folders. It doesn't work with aliases since the location of the Original file will be used.

You will need to wrap any tell statement targeting a particular app in the using terms from block. Also, you may want to assign the mediaAppName as a property or global in order to access it throughout the scope of more elaborate scripts.

UPDATED, July 31, 2019. Changed target "Apple TV" to just "TV", which is how the app is targeted in the latest macOS 10.15 betas. Note that the name required for TV app's "Scripts" folder's container is still "Apple TV".

June 25 2019 - 10:14 am

Catalina Public Beta

Yesterday, Apple released the first beta of macOS 10.15 Catalina to users in the Apple Beta Software Program. If you're in the program and have installed the beta, well, surprise! Scripts and apps written for iTunes will not work on it. That's because there is no version of iTunes in the beta for scripts and apps to work with.

As you are no doubt aware, Apple has replaced iTunes with the Music, Apple TV, Podcasts and Books apps. Between now and the official release of Catalina in the fall, I will be updating very many scripts to work with the Music and Apple TV apps—Podcasts and Books do not have AppleScript support.

Providentially, scripting the Music and Apple TV apps is very much like scripting for iTunes. Their scripting definitions are virtually identical. In many cases, for very simple scripts, updating will merely require changing the target from "iTunes" or "com.apple.iTunes" to "Music"/"com.apple.Music" or "Apple TV"/"com.apple.TV". More elaborate scripts may require additional modifications and security accommodations.

Thus, there will essentially be two sets of scripts on this site: those written for iTunes that can only run under macOS 10.14 and earlier and those for the newer media apps that can only run under macOS 10.15 and later.

I hope to have a first batch of Catalina-compatible scripts posted in about a week.

June 22 2019 - 4:33 pm

About Catalina's New Media Apps

Apple has posted an article, About the upcoming changes with iTunes on Mac, which describes the new media apps coming in macOS 10.15 Catalina.

June 4 2019 - 10:53 am

First Thoughts About Music.app

Apple debuted Music.app and Apple TV.app at WWDC yesterday. The macOS 10.15 Developer Beta was released and I've installed it. All in all, I'd say things are looking good for scripting the media apps in macOS 10.15.

  1. There is no iTunes.app in Catalina. Surprisingly! I thought Apple would keep a "legacy" iTunes around, in the same way QuickTime Player 7 and Aperture were allowed to languish. But I'm guessing the new new media apps work well enough that such a strategy was deemed unnecessary.
  2. Music and Apple TV have AppleScript support. Podcasts app does not.
  3. Current iTunes scripts will not work with Music.app or AppleTV.app. At least, not without some slight modifications. Music.app's scripting definitions file is virtually the same as iTunes (likewise the Apple TV.app). So scripts that target application "iTunes" will need to target application "Music" or "Apple TV". There may be other changes necessary.
  4. The Music.app Script Menu Lives! Simply create the "Music/Scripts/" folders in the Library folder, put at least one script in it and the Script menu will appear in Music.app. I haven't tried this with the Apple TV app, but I'm betting it works the same.
  5. There doesn't appear to be an automatically updated "iTunes Library.xml" file. Holding out hope this will be available in a later version (or perhaps I'll stumble over something). This XML file is used by third-party apps to quickly get information about the library. XML files can be user-exported but not having an automatically updated XML is inconvenient. This was being phased out anyway. I haven't tested the iTunesLibrary/ITLibrary framework under Catalina yet which may be a workaround.
  6. No Column Browser (sad).

If you are a rabid iTunes user and are chomping at the bit to try Music.app: TAKE THAT BIT OUT OF YOUR MOUTH! I would not recommend using the Developer or Public Betas on a main machine "just to see". You will not be able to go back without enormous difficulty. If you must install a beta, use a separate partition or virtual machine. Otherwise, wait until the official release.

I will try and update some scripts and apps for Music.app in the coming days and weeks. My Summer is going to be quite busy!

May 18 2019 - 2:46 pm

UPDATED: Music Folder Files Not Added v6.0

Music Folder Files Not Added has been updated to v6.0. This application will list the file paths of the media files in your designated "iTunes Media" folder which are not associated with any tracks in iTunes' track library. Additionally, you can select a different parent folder and its contents will be compared to the iTunes library. Includes options to Filter results, Add a selection of found files to iTunes, move them to the Trash, and Export a text file listing the file paths.

I was getting some reports from users who were getting false positives, so I tweaked the text normalization routines in the hopes of minimizing ambiguous results. Other minor issues were addressed as well.

You can use Music Folder Files Not Added free for ten days, after which a registration can be purchased for $1.99. More information, a video demo and download is available on this page. Current users can "Check for Update..." in the applet's main menu.

May 13 2019 - 4:57 pm

iTunes 12.9.5.5

Apple has included iTunes 12.9.5.5 with the macOS 10.14.5 update. The previous version of iTunes was 12.9.4.94. The new version is only available when the operating system is updated and there is no stand-alone installer.

There doesn't appear to be too much different. However, as in iOS 12.3, there are some minor changes to Apple Music's For You page. For example, the 4x4 "because you like/listen" blocks of album recommendations have been replaced with 4 Genre groups of 12 albums and playlists. [Update: this was rolled out to all users.]

This is probably the last version of iTunes that Apple releases before the macOS 10.15 beta is released to developers in June at WWDC; it is presumed that a new Music.app will debut then as well.

May 10 2019 - 8:17 am

NEW: Make Tags All Caps v1.0

I got a request from a DJ'ing Correspondent who had been manually changing some of his tags to all caps so they'd be easier to read on the decks under dim dance floor lights. (Are they still called "decks"?)

Anyway, to put a finer point on it, he sent me a snap of his handiwork:

Frankly, I don't think I had ever seen this done. And it reminded me of these:

iTunes is, afterall, "jukebox" software. These are called title strips and are probably familiar to anyone who has ever seen a jukebox in a diner or the like. And for the most part the text was always all caps.

Manually changing the case of track tags in iTunes must have been painful.
Make Tags All Caps will change the text in your choice of the Name, Artist, Album, Comments and/or Composer tags of the selected iTunes tracks to ALL CAPS quickly.

More info and download is here.

May 7 2019 - 10:15 am

NEW: New Shuffled Playlist v1.0

When Apple changed the Shuffle behavior of playlists a few years ago—in the Olden Times the actual Play Order of a playlist would be changed by designating it "shuffled"—the only way to see the order of play was to click Up Next.

This still bothers some users. One of them asked me if something could be done to show the actual new shuffled play order in the playlist.

New Shuffled Playlist will create a copy of a selected playlist or folder playlist with its tracks' Play Order randomly shuffled. The new playlist will be named using the original playlist's name with " - Shuffled*" appended at the end.

If a " - Shuffled*" playlist is selected it will be shuffled again; if a " - Shuffled*" playlist already exists for a selected playlist then it can be shuffled again.

This works great with a keyboard shortcut. More information and download is here.

May 4 2019 - 11:45 am

ViTLXML (View iTunes Library XML) App Updated

ViTLXML can open any iTunes XML file and display it in a familiar, user-friendly interface. In the screenshot below, the XML is an old iTunes v12.2 Library XML file last saved in 2015:

Using ViTLXML you can:

  • Inspect the contents of other libraries without having to load them into iTunes
  • Display raw XML text alongside formatted views of track entry metadata
  • Use Search and Filter options for fine-grained examinations
  • Detect which track entries may have corresponding entries in the current library
  • Drag out accessible media files to copy or add to iTunes
  • Export playlist information, with options to replace file path components
  • Export Smart Playlist criteria from other XMLs into current iTunes library
  • Copy accessible files to new location with referencing XML playlist file
  • Evaluate an old library against the current iTunes library
  • Reconstruct older playlists with current tracks
  • Check for XML corruption and anomalies

ViTLXML is easy to use. Read the Quick Help page for a rundown of features and tools.

ViTLXML is handy to have if you manage multiple libraries or want to examine or repurpose old back-ups or just need a different way of looking at your current iTunes library. Download the demo and try it out for yourself now.

May 3 2019 - 1:54 pm

Do Some (Very) Rough Audio Editing in iTunes

This is not a tip for everyone.

You may be aware that Apple added some editing capabilities to Quick Look. For instance, Markup is available to edit text and image documents and Trim is available to edit video and audio files.

Using the script Have a Quick Look, a track can be selected in iTunes and its file displayed in a Quick Look window, via the qlmanage command:

The scrub/trim area becomes available after clicking the Trim button which initially appears in the upper-right corner of the window.

If this suggests to the suggestible reader that this makes a handy audio editor, think twice: editing this way is not very precise and accepted changes are permanent. But, for trimming large audio files of "dead air" or crowd noise or what have you, some may find it convenient.

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.