AppleScript for Apple Music triggered via KM very slow after updating to Catalina

I have a script that searches through selected tracks in a Music playlist and performs several find and replace actions to clean up the track names.

Before it used to run through a list of 100 tracks in a few seconds... now its very slow and it seems like its changing each track one-by-one whereas before it was changing them so fast it seemed like it was changing all the tracks names at the same time. Can someone please let me know if I need to change my script? The only change I made since upgrading to Catalina was to change the name of the app being referenced from iTunes to Music.

Here's part of my script. It finds and replaces hundreds of names. I removed most of the names just so i can paste it here without being too long of a script.

global search_for, replace_with, at_least_one_found, find_this, replace_this
set myList to {" - - ~ - ", "Instrumental~", " - By ~ - ", "Ny Bangers - ~New York Bangers - ", "New New York ~New York ", "New York Bangers - New York Bangers - ~New York Bangers - ", " - / - ~ - ", "The Cratez - The Cratez - ~The Cratez - ", " - - ~ - ", " / ~ x ", "No Tags ~ "}

tell application "Music"
  set this_playlist to view of front browser window
  set this_playlist_name to name of this_playlist
  set dd_tracks to "all tracks in \"" & this_playlist_name & "\""
  set my_choice to "Song Name" as text
end tell
repeat with myItem in myList
  set theText to myItem
  splitText(theText, "~")
  set myResult to result
  set search_for to item 1 of myResult as string
  set find_this to search_for as text
  set replace_with to item 2 of myResult as string
  set replace_this to replace_with as text
  tell application "Music"
    set these_tracks to (search this_playlist for find_this)
    repeat with i from 1 to count of these_tracks
      set this_track to item i of my these_tracks
      if this_track's name contains find_this then
        try
          set this_track's name to my srch_and_replace(this_track's name)
        end try
      end if
    end repeat
  end tell
end repeat

--=======================================--

on splitText(theText, theDelimiter)
  set AppleScript's text item delimiters to theDelimiter
  set theTextItems to every text item of theText
  set AppleScript's text item delimiters to ""
  return theTextItems
end splitText

on convertListToString(theList, theDelimiter)
  set AppleScript's text item delimiters to theDelimiter
  set theString to theList as string
  set AppleScript's text item delimiters to ""
  return theString
end convertListToString

to srch_and_replace(txt)
  set txt2 to txt
  considering case
    set AppleScript's text item delimiters to find_this
    set the item_list to every text item of txt2
    set AppleScript's text item delimiters to replace_this
    set txt2 to the item_list as string
    set AppleScript's text item delimiters to ""
    if txt2 ≠ txt then set at_least_one_found to true
    txt2
  end considering
end srch_and_replace

Any help would be greatly appreciated!

Aaron

Hey Aaron,

Unfortunately I don't have access to Catalina to test, but the problem is most likely the AppleScript implementation in Music.

Please take the time to complain directly to Apple:

-Chris

Thanks Chris will do

1 Like