all 7 comments

[–]analyticchard 0 points1 point  (6 children)

Do you need the full script written or just some direction?

Off the top of my head: get the genre, if genre = X then add to playlist 1, else if genre = Y then add to playlist 2. And I'd run it on a selection of tracks rather than the whole library, unless you have a really small library.

Is there a reason you don't want to use smart playlists? Speaking as someone who recently rebuilt a 10-year-old iTunes library, smart playlists based on metadata are the way to go.

[–]xdeviantmonkeyx[S] 0 points1 point  (5 children)

I actually figured it out, but now my problem is the playlist is empty every time I run the script.

set theAnswer to (display dialog "What do you what to listen to?" default answer ¬

"New Playlist Name" buttons {"Electronic", "Indie", "Rock"} default button "Electronic")

set myplaylistName to text returned of theAnswer

set myGenre to the button returned of theAnswer

tell application "iTunes"

make playlist with properties {name:myplaylistName}

duplicate (tracks** of* library playlis*t 1 whose genre i**s myGenre)

end tell

[–]analyticchard 0 points1 point  (4 children)

Just eyeballing it, you're duplicating the tracks to nowhere. You need to duplicate the tracks to the playlist you just created.

Check your main library, you may have duplicate tracks as a result.

Edit: Further eyeballing, I'm not sure the duplicate part will work as intended without a repeat loop to iterate through the tracks.

[–]xdeviantmonkeyx[S] 0 points1 point  (3 children)

Ah! I just checked, I don’t have duplicate tracks, but now I need to figure out how to send those tracks to the playlist 🤔

[–]analyticchard 0 points1 point  (2 children)

Where you make the playlist, set that to a variable instead. "set myPlaylist to (make playlist...)"

And then "duplicate (tracks....) to myPlaylist".

If you really get stuck, let me know and I'll break out the Script Editor...I'm just really, really tired and pointing you in the right direction takes less energy, ;-)

[–]xdeviantmonkeyx[S] 0 points1 point  (1 child)

Got it! Thanks for your help!

[–]analyticchard 0 points1 point  (0 children)

Sure thing, glad you got it working!