I have multiple genres in comments from different programs and want to sort and delete duplicates
an example comment for a song could be:
Pop,pop,r&b,female vocalist,sad,ballad,hip-hop,soul,english,r&b,pop,reggae,female vocalists,2006,00s,dance,r&b,
the script below will do 10 tracks then you start it again, I have tried to do it for 50 or 100 then itunes comes back with error message can’t save library.
Is there anyway to get script to go through whole library and faster? Any ideas would be appreciated.
repeat 10 times
tell application “iTunes”
activate
reveal current track
set someText to comment of current track
set AppleScript’s text item delimiters to {“,”}
set delimitedList to every text item of someText
set the_list to delimitedList
set return_list to {}
repeat with an_item in the_list
if return_list does not contain an_item then set end of return_list to (contents of an_item)
end repeat
end tell
simple_sort(return_list)
tell application "iTunes"
next track
end tell
end repeat
on simple_sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to “”
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is “” then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
set someText to sorted_list
set AppleScript's text item delimiters to {","}
set newdelimitedList to every text item of someText
set the_list to newdelimitedList
set return_list to {}
repeat with an_item in the_list
if return_list does not contain an_item then set end of return_list to (contents of an_item)
end repeat
tell application "iTunes"
activate
reveal current track
tell current track
try
set comment to every text item of sorted_list as text
end try
end tell
end tell
end simple_sort