The script for batch exporting playlists from Apple Music app is throwing up the execution error:
"The variable all_ps is not defined. (-2753)"
This is the portion of the code in question:
(-- GET ALL PLAYLISTS FROM APPLE MUSIC)
try
set all_specialps to (get name of every user playlist whose special kind is not none)
set all_userps to (get name of every user playlist whose smart is false and special kind is none)
set all_smartps to (get name of every user playlist whose smart is true and special kind is none)
set delim to "--------------------------------------------------"
set delim_specialpl to "---------------- Special Playlists: ----------------"
set delim_userpl to "------------------ User Playlists: -----------------"
set delim_smartpl to "---------------- Smart Playlists: -----------------"
set all_ps to "{}"
if ((length of all_specialps) > 0) then
set the end of all_ps to delim
set the end of all_ps to delim_specialpl
repeat with ps in all_specialps
set the end of all_ps to ps
end repeat
end if
if ((length of all_userps) > 0) then
set the end of all_ps to delim
set the end of all_ps to delim_userpl
repeat with ps in all_userps
set the end of all_ps to ps
end repeat
end if
if ((length of all_smartps) > 0) then
set the end of all_ps to delim
set the end of all_ps to delim_smartpl
repeat with ps in all_smartps
set the end of all_ps to ps
end repeat
end if
end try
I cannot see what is not defined about all_ps from this, total noob, any help v gratefully received
Changed "set all_ps to "---------------All Playlists:--------------" to no effect, same issue thrown up.
In a try statement, any error will jump to a separate set of statements, skipping whatever statements follow the error. There will be no indication unless the
on errorportion of thetrystatement is included to handle the error (even if it is just to log that there was an error).In this case, the error is from trying to get the name of a list of playlists, since lists don't have a name property. This skips everything else in the
trystatement, including where theall_psvariable is declared. Once that is fixed, the next error(s) would be from trying to set the end of a string to something.Strings are immutable, so you can’t add stuff to them like that - a new string needs to be built from the desired parts using the concatenation operator (
&). Your posted script can still be used withall_psset to a list (adding to the end of a list is OK), which can be converted later into a string, for example: