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:
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