Sorry this is lengthy, but I like to give as much info as possible.
iMac mid-2011, OS 10.10.2
iTunes 12.1.0.50
Script Editor 2.7 (176)
Setup:
I have iTunes Prefs/Advanced set to not “Keep iTunes Media folder organized” and not to “Copy files to iTunes Media folder when adding to library”.
The reason being is that I have a ton of “old time radio” programs (aka “OTR”). They are kept in a folder named “OTR Programs” and within that there is a folder for each program. These folders contain all the individual programs with the track name being first broadcast date then the track name. I sort them in Finder by that date, in other words, by Name.
Example:OTR Programs/Dragnet/
1951-10-18 The Big Story Man.mp3
1951-10-25 The Big Market.mp3
This is because they are considered “Music” by iTunes and I prefer my own filing methods for my media, keeping the OTR separate from Music in Finder.
Anyway, for my Question:
I am very happy with my filing methodology, but within iTunes I only want the track names to have the name and the date moved to the Comments field.
I have tried a number of ways to write an Applescript to make this move (only if the first 4 letters of the name is ranged “0000” to “9999”) as not all the names will be formatted this way.
I was going to use Automator to grab the selected tracks in iTunes and then run the Applescript.
Any ideas, suggestions, tips, help, or an actual script would be most appreciated.
tell application "iTunes"
repeat with atrack in selection
tell atrack
set d to text 1 thru 10 of name
try
date d
-- will error if not a date and thus skip this one
set name to text 11 thru -1 of name
set comment to d & space & comment
end try
end tell
end repeat
end tell
I will lay this possibly a bit better and explain why I do this…
in Finder, my file system for media is thus:
User/ Media Library OTR Programs/ Dragnet/
1951-10-18 The Big Story Man.mp3
1951-10-25 The Big Market.m93
The same mp3’s in iTune are thus:
Album: Dragnet Media Kind: Music Genre: (includes)OTR Name: The Big Story Man Comments: 1951-10-18 Name: The Big Market Comments: 1951-10-25
Knowing that OTR episode numbers aren’t always known in the internet, I sort them Program (Series)-Broadcast Date. After sorting them, just to keep iTunes happy I apply track numbers to them.
Seems like a good idea, so you can select tracks and go on at your pace, but you can use it from the Script Editor also.
Sorry for the untested script. This should work:
tell application "iTunes"
repeat with atrack in selection
tell atrack
set n to name of atrack
set d to text 1 thru 10 of n
try
date d
-- will error if not a date and thus skip this one
set n to (text 11 thru -1 of n)
set name to n
set comment to d & space & comment
end try
end tell
end repeat
end tell