Is it possible to set a Music track’s “Use work and movement” tag using AppleScript?

I am cleaning up the tags for my classical music in Music.app. One thing I have found is that if I set the ‘work’ and ‘movement’ tags on my master Apple Lossless tracks, when I then use Music to encode those tracks as AAC, it doesn’t write out these tags to the AAC file. To be clear, the Music app’s database retains all these tags and shows them in the Music app. But the underlying file doesn’t have the metadata, so if I were to ever remove the files or move them to another Mac, I would lose all the work and movement details.

I’ve written a simple AppleScript that tells Music to re-write most of these tags, which causes it to then write them out to the file. However, the one tag I have not been able to either get or set is the ‘Use work and movement’ tag. I can see this tag set in the original Apple Lossless file using Subler:

image

Does anyone know of a way to get/set this tag from an AppleScript? My current script is below for reference. Thanks!

(* Embed classical music tags
 *
 * When Music encodes (e.g. ‘Create AAC Version’) tracks that have classical music tags, although it preserves
 * the tags in its database, it does not write them as metadata in the underlying file. This script reads the tags
 * and writes them back so that they are embedded in the file’s metadata. In between reading the tag value and
 * writing it back, a temporary tag is written, as if the tag doesn’t change then Music will not write metadata to the file.
 *
 * Currently supported tags:
 *	• Work name
 *	• Movement name
 *	• Movement number
 *	• Movement count
 *
 *
 * author: <software at OakAndApple.org>
 * date: 8 October 2023
 * version: 1.0
 *
 * 1.0 (8-10-2023): initial release
 *)

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

on run
	tell application "Music"
		set vTracks to selection
		repeat with vTrack in vTracks
			set vWork to work of vTrack
			set work of vTrack to "temp"
			set work of vTrack to vWork
			
			set vMovement to movement of vTrack
			set movement of vTrack to "…"
			set movement of vTrack to vMovement
			
			set vMovementNumber to movement number of vTrack
			set movement number of vTrack to 0
			set movement number of vTrack to vMovementNumber
			
			set vMovementCount to movement count of vTrack
			set movement count of vTrack to 0
			set movement count of vTrack to vMovementCount
		end repeat
	end tell
end run

I don’t see a property that controls this.

FWIW, the interface is different in Sonoma. There’s no longer a checkbox in the Get Info window, instead there’s a dropdown that controls visibility of the Title field vs. the 4 classical music fields.

Thanks for that – it’s actually the same in all previous versions of Music (and I think in iTunes since it first supported these tags). The tickbox appears if you select multiple tracks and Get Info on them as a group.

I set those tags via Scripting Bridge (in iTunes) and when I open the file in Kid3 (external tag editor) they show up. So the are written to the m4a file.

Yes, if you set those tags either in iTunes or via AppleScript, they get written to the file, which is why I developed my script. The reason I needed it is because if iTunes/Music re-encodes a file that has those tags, it doesn’t write them to the newly encoded file.

Have you managed to set the ‘Use work and movement’ tag with your scripting solution? I don’t see it listed in the Kid3 screenshot. Thanks!

That sucks about the encoding… I would use an external encoder. dBPowerAmp
Is my choice as it can encode AAC files at 512kB. And will rewrite all tags (or conditionally rewrite them) iTunes/Music Mac but rate for encoding is 256kB. Unless you use LoseLess AAC encoder.

About the “use Movement and Work Numbers”
My understanding is that is only used internally in iTunes. It changes the “Displayed Info” of a current playing track using the Work/Movement info… (as opposed to the Title / Artist
/ Album). This is not written to the file. It is stored in iTunes library database for it own iternal use. It is not a MetaData tag ever written to the file.