It might be a memory issue with getting that many tracks at once.
I made a more complex script that will get the tracks 2000 at a time.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property albArts : {}
property sortAlbArts : {}
property Albs : {}
property SortAlbs : {}
property locations : {}
property trackNames : {}
property trackIDs : {}
on run
local sdt, edt, fileTracks, aTrack, flag, ct, cstr, dur, alist, remainder
set flag to true
if flag then
set progress description to "Getting Music Tracks…"
set progress additional description to "(0)"
set progress total steps to -1
end if
set sdt to current date
tell application "Music"
set currPL to playlist "Library"
set ct to count (file tracks in currPL whose kind is not "Internet audio stream")
set remainder to ct mod 1000
repeat with i from 1 to ct div 1000
set {end of trackIDs, end of trackNames, end of albArts, end of sortAlbArts, end of Albs, end of SortAlbs, end of locations} to {id, name, album artist, sort album artist, album, sort album, location} of tracks ((i - 1) * 1000 + 1) thru (i * 1000) in currPL
set my progress additional description to "(" & (i * 1000) & ")"
end repeat
if remainder > 0 then
set {end of trackIDs, end of trackNames, end of albArts, end of sortAlbArts, end of Albs, end of SortAlbs, end of locations} to {id, name, album artist, sort album artist, album, sort album, location} of tracks (i * 1000) thru (i * 1000 + remainder) in currPL
end if
end tell
-- flatten lists albArts,sortAlbArts,Albs,SortAlbs,locations
repeat with alist in {a reference to trackIDs, a reference to trackNames, a reference to albArts, a reference to sortAlbArts, a reference to Albs, a reference to SortAlbs, a reference to locations}
set alist to contents of alist
set tmp to {}
repeat with i from 1 to count (contents of alist as list)
set tmp to tmp & item i of alist
end repeat
set contents of alist to tmp
end repeat
set cstr to " of " & ct & " - "
repeat with i from 1 to ct
if (i mod 100) = 0 then
set dur to ((current date) - sdt) as integer
set my progress additional description to "\"" & (item i of trackNames) & "\" - ID:" & (item i of trackIDs) & ", index " & i & cstr & my convertToHMS(dur) & ", eta - " & my convertToHMS((dur / i * (ct - i)) as integer)
end if
end repeat
convertToHMS(((current date) - sdt) as integer)
end run
on convertToHMS(n)
local dds, hhs, mns, secs
set dds to n div 86400
set n to n mod 86400
set hhs to n div 3600
set n to n mod 3600
set mns to n div 60
set secs to n mod 60
return (item (((dds > 0) as integer) + 1) of {"", (dds as text) & ":"}) & (text -2 thru -1 of ("0" & hhs)) & ":" & (text -2 thru -1 of ("0" & mns)) & ":" & (text -2 thru -1 of ("0" & secs))
end convertToHMS
Only one problem. This script will error out when it hit a track that is an “Internet audio stream”. They don’t have a location property.
So instead, here’s a version that get all the properties of the tracks for later parsing.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property trackNames : {}
on run
local sdt, edt, fileTracks, aTrack, flag, ct, cstr, dur, alist, remainder
set flag to true
if flag then
set progress description to "Getting Music Tracks…"
set progress additional description to "(0)"
set progress total steps to -1
end if
set sdt to current date
tell application "Music"
set currPL to playlist "Library"
set ct to count (file tracks in currPL)
set remainder to ct mod 1000
repeat with i from 1 to ct div 1000
set trackNames to trackNames & properties of tracks ((i - 1) * 1000 + 1) thru (i * 1000) in currPL
set my progress additional description to "(" & (i * 1000) & ")"
end repeat
if remainder > 0 then
set trackNames to trackNames & properties of tracks (i * 1000) thru (i * 1000 + remainder) in currPL
end if
end tell
set cstr to " of " & ct & " - "
repeat with i from 1 to ct
if (i mod 100) = 0 then
set dur to ((current date) - sdt) as integer
set my progress additional description to "\"" & (name of item i of trackNames) & "\" - ID:" & (id of item i of trackNames) & ", index " & i & cstr & my convertToHMS(dur) & ", eta - " & my convertToHMS((dur / i * (ct - i)) as integer)
delay 1
end if
end repeat
convertToHMS(((current date) - sdt) as integer)
end run
on convertToHMS(n)
local dds, hhs, mns, secs
set dds to n div 86400
set n to n mod 86400
set hhs to n div 3600
set n to n mod 3600
set mns to n div 60
set secs to n mod 60
return (item (((dds > 0) as integer) + 1) of {"", (dds as text) & ":"}) & (text -2 thru -1 of ("0" & hhs)) & ":" & (text -2 thru -1 of ("0" & mns)) & ":" & (text -2 thru -1 of ("0" & secs))
end convertToHMS