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

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 ?



Solution 1:[1]

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.

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Robert Kniazidis