eustacescrubb
07-01-2003, 08:28 AM
This script (http://www.malcolmadams.com/itunes/scripts/scripts09.shtml#removenchars) deletes a speicified number of characters from the front of the track's name. This morning I needed it to get rid of stuff in front of an artist name (I wanted to get "Bob Marley W/" off the front of every track's artist name in Chant Down Babylon.) So I initially modified the script to do this, but while I was at it, I thought it'd be useful for me to go ahead and modify it so I could choose between tags I'm likely to edit in the future.
initially, I edited this block of code:
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_name to (get thisTrack's name)
set thisTrack's name to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_name)
end repeat
to look like this:
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_artist to (get thisTrack's artist)
set thisTrack's artist to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_artist)
end repeat
For the final version, I wanted it to allow me to choose between artist, album, and track name, so I added this list to the beginning of the script:
property tagList : {"Name", "Artist", "Album"}
Then, where the block of code above was, I added a prompt to allow the user to choose:
set tagChoice to (choose from list tagList with prompt "Which tag's field would you like to edit?") as string
And finally, told it what do based on how the user chose:
if tagChoice is item 1 of tagList then
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_name to (get thisTrack's name)
set thisTrack's name to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_name)
end repeat
end if
if tagChoice is item 2 of tagList then
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_artist to (get thisTrack's artist)
set thisTrack's artist to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_artist)
end repeat
end if
if tagChoice is item 3 of tagList then
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_album to (get thisTrack's album)
set thisTrack's album to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_album)
end repeat
end if
Works like a champ!
initially, I edited this block of code:
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_name to (get thisTrack's name)
set thisTrack's name to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_name)
end repeat
to look like this:
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_artist to (get thisTrack's artist)
set thisTrack's artist to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_artist)
end repeat
For the final version, I wanted it to allow me to choose between artist, album, and track name, so I added this list to the beginning of the script:
property tagList : {"Name", "Artist", "Album"}
Then, where the block of code above was, I added a prompt to allow the user to choose:
set tagChoice to (choose from list tagList with prompt "Which tag's field would you like to edit?") as string
And finally, told it what do based on how the user chose:
if tagChoice is item 1 of tagList then
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_name to (get thisTrack's name)
set thisTrack's name to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_name)
end repeat
end if
if tagChoice is item 2 of tagList then
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_artist to (get thisTrack's artist)
set thisTrack's artist to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_artist)
end repeat
end if
if tagChoice is item 3 of tagList then
repeat with i from 1 to ix
set thisTrack to item i of theBigList
set thisTracks_album to (get thisTrack's album)
set thisTrack's album to (text (this_many_front_end_characters + 1) thru -1 of thisTracks_album)
end repeat
end if
Works like a champ!