I'm trying to run the following script in the Apple Music app to use proper English capitalisation on the selected tracks (ignoring anything that is in all capital letters to start)
So for example the track name...
opportunities (Let's MAKE lots of money) (Reprise)
should become
Opportunities (Let's MAKE Lots of Money) (Reprise)
It looks like it should work, i'm getting no syntax errors or errors at all - it's simply not doing anything at all to the tracks selected in Apple Music.
on properEnglishCapitalization(textString)
set newText to do shell script "echo " & quoted form of textString & " | perl -pe 's/(?<=\\b|^)(\\w)/\\U$1/g'"
return newText
end properEnglishCapitalization
tell application "Music"
set selectedTracks to selection
if selectedTracks is not {} then
repeat with aTrack in selectedTracks
set trackName to name of aTrack
set newName to my properEnglishCapitalization(trackName)
if newName is not trackName then
set name of aTrack to newName
set loved of aTrack to loved of aTrack
end if
end repeat
end if
end tell