When you get the tracks from the global playlist from Itunes/AppLe Music with Applescript how do you get only filetracks

182 Views Asked by At

When you get the tracks from the global playlist from Itunes/Apple Music with Applescript how do you get only filetracks

e.g

I can do

return tracks of playlist 1

but that will return all tracks including those on the cloud, I only want the one that are actually stored on the harddrive

I see you can use a filter but how do I filter to only retrieve filetracks ?

2

There are 2 best solutions below

0
Hendrik On BEST ANSWER

Robert's answer is almost right.

tell application "Music" to return file tracks of playlist 1

works for most instances of the AppleScript class playlist, but not for all of them, because the element file tracks is only declared in various sub-classes, but not in the playlist class itself.

For example, it does not work, if the playlist happens to be a radio tuner playlist or an audio CD playlist. They don't declare the file tracks element.

So before calling file tracks of, you should check the class property of the playlist to ensure your playlist object actually has a file tracks collection.

0
Robert Kniazidis On
tell application "Music" to return file tracks of playlist 1