dougscripts.com

August 12 2016 - 5:50 pm

A Couple of Work and Movement Scripts

In case you hadn't heard, the latest beta of iTunes 12.5 (available to Developers and Sierra Public Beta participants) has added Work, Movement Name, and Movement Number/Count tags for music tracks (well, all tracks have these tags, but iTunes' contextual UI may keep them from showing up in contexts other than Music.). When the Work and Movement tags of a track are used, iTunes constructs a new display Song Name for the track using the Work, Movement Number and Movement Name tags. iTunes even converts the Movement Numbers into Roman numerals for the aggregated name. The original Song Name is still available, it just mostly isn't visible. (Kirk and I talk a little about these changes in Episode #13 of The Next Track podcast.)

You may want to edit your track tags to take advantage of these new Work and Movement tags. What I found was that most of what I wanted to use in those tags was already in the Song Name (eg: "Brandenburg Concerto No. 1 in F, BWV 1046: I. Allegro"), but the Get Info panel won't display the Song Name field together with the Work and Movement fields in order to copy some text from the former to one of the latter. I want to be able to copy "Brandenburg Concerto No. 1 in F, BWV 1046" to the Work tag and "Allegro" to the Movement tag. But the Song Name isn't visible.

So I wrote a script that grabs the text of the Song Name and displays it in a text field; the text can be edited however required and when the "OK" button is clicked, that text will be copied to the Movement Name.

(I'd be deleting the highlighted text.) This has to be done one track at a time; there's really no easy way to automate the selection of text since conventions vary about that sort of thing. So, you have to do some of the work. A keyboard shortcut really helps here.

A second script works similarly for the Work Name tag, except you can choose more than one track at a time (the first selected track's Song Name is used) to which to apply the edited text. It will also increment each selected track's Movement Number/Count starting with 1 based on the tracks' Play Order.

In this case, I'd have selected the four tracks comprising the movements of this Work, deleted the highlighted text, and then pressed OK. Make sure the selected tracks are sorted by Play Order (this should be done in Songs or Playlist View, ideally) so that the Movement Number increments for each track correctly.

Just to be clear, the original Song Name remains as is. It's just that, when the Work and Movement tags are used, you'll rarely see it. In most contexts, you'll only ever see the aggregated Work-Movement Number-Movement name.

Here are the scripts:

UPDATE: These scripts can be downloaded as part of the Work and Movement Scripts.

Remember, they will only work with iTunes 12.5 using the Sierra beta (and later, of course).

For working with the Movement tag of a single selected track:

(*

This script will get the Song Name of the single selected track

and display it in a text field so that portions of its text can

be used for the selected track's Movement Name.

*)

tell application "iTunes"

set sel to selection of front browser window

if (count of sel) is not 1 then

try

display dialog "Select a single track..." buttons {"Quit"} with icon 0

end try

return

end if

set thisTrack to item 1 of selection

set songName to (get name of thisTrack)

set userOptions to display dialog "Edit for Movement Name and then click OK." default answer songName

try

set movement of thisTrack to text returned of userOptions

end try

end tell

For working with the Work tag of one or more selected tracks and incrementing the Movement Number of each:

(*

This script will get the Song Name of the first selected track--

although more than one track can be selected--and display it in

a text field so that portions of its text can be used for the

selected tracks' Work Name.

Additionally, each track's Movement Number and Count

will be set according to its Play Order starting with 1.

*)

tell application "iTunes"

set sel to selection of front browser window

if sel is {} then

try

display dialog "Nothing is selected..." buttons {"Quit"} with icon 0

end try

return

end if

set c to (count of sel)

set songName to (get name of item 1 of sel)

set userOptions to display dialog "Edit for Work name and then click OK." default answer songName

repeat with i from 1 to c

set thisTrack to item i of sel

try

set work of thisTrack to text returned of userOptions

set movement number of thisTrack to i

set movement count of thisTrack to c

end try

end repeat

end tell

To load them at your house, click the little AppleScript document icon beneath each listing and your Script Editor will create a new Script Editor document containing the code. Save the scripts named whatever you like to your Home/Library/iTunes/Scripts/ folder so they will appear in the iTunes Script menu. I would definetly assign keyboard shortcuts for these, even just temporarily, and they will fire much faster.

I call it knitting when I use multiple scripts to perform mini-tasks on batches of tracks like this.

Site contents © 2001 - 2024 (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.