I searched for 'playlists' and 'add to playlist' but didn't see what I'm looking for. Maybe I missed it?
What I'd like to do:
While listening to a playlist, I'd like the ability to add the current track to one of two other playlists.
Expanding further, I have a library I share with others in the household, so using the Like, star ratings, etc., doesn't work well. I've created a folder for myself and under that, these playlists: Like, Don't Like, and Sorting Hat (all songs in the library where they do not belong to either of the aforementioned playlists).
So, while listening to the playlist 'Sorting Hat' while at my desk doing other things, I'd like to fire off a KBM menu where I can select which playlist to add the current song to (Like or Don't Like).
I really thought I'd find something about adding a current song to a playlist, but I'm clearly missing it.
Here's a quick attempt which worked. It adds to a playlist called Test. It can be made better by added option to ask for playlist name.
This should do it:
[test] Add iTunes Track to One of Two Playlists.kmmacros (3.1 KB)
- Changed macro to use a local variable
You guys ROCK! I couldn't see the forest for the trees on this one. Many, many thanks. (I love this community).
Neither of these worked for me unfortunately. The menu is disabled using the suggestion by @bolero In the suggestion by @Tom , it doesn't end up appearing in the playlist.
Likely the script would need to be updated since iTunes is now Music. Can’t confirm this since I’m away from my desk but just spitballing here.
In the AppleScript, try changing this part:
tell application id "com.apple.iTunes"…
tell application "Music"…
Hi @Jim, "com.apple.iTunes" causes an interaction with iTunes, whereas changing it to music causes nothing to happen.
The playlist popup comes up, but nothing is added to the playlist once I specify
Odd. Then try: tell application id "com.apple.Music"
I can confirm that works. Just tried now (running Big Sur and Music).
The one caveat seems to be that the track already needs to be in a Playlist (or has been Added to the Library) before this will work. Playing the track from within a Playlist (or from the Library) and running the Macro allows it to be added to another Playlist. But if the track is just played direct from Apple Music (i.e. it hasn't yet been added to the Library) and the Macro is run, it fails to add it to a Playlist. Not sure exactly why - maybe it is the command "duplicate"? (EDIT - Just found out this is a quirk going right back to iTunes days. Tracks played direct from Apple Music have the "Add to Playlist" menu item grayed out. Frustratingly the right-click context manu still works but is not as easy to automate).
Anyway, this is the AppleScript that works (as long as the playing track is already in a Playlist or is being played from the Library)
tell application id "com.stairways.keyboardmaestro.engine"
set inst to system attribute "KMINSTANCE"
set thePlaylist to getvariable "Local__Playlist" instance inst
tell application "Music" to duplicate current track to playlist thePlaylist