Thursday, December 13, 2018

#1 2018-12-04 04:29:48 pm

Jono
Member
Registered: 2008-07-08
Posts: 95

iTunes: Add track to beginning/top of specified playlist?

I'm trying to create a script that will add the song that's currently playing in iTunes to the beginning of a specified playlist.

The script below adds the currently playing song to the specified playlist, but always adds it add the bottom.

Applescript:


tell application "iTunes"
   duplicate current track to beginning of user playlist "My Playlist"
end tell

Whether I specify 'track to beginning of user playlist', 'track to end of user playlist; or just 'track to user playlist' it always adds the track to the bottom of the playlist.

I'm guessing I'm not doing it correctly (rather than a bug with iTunes).

Does anyone know how to get this to work as I'm wanting?

Offline

 

#2 2018-12-11 11:09:39 pm

technomorph
Member
Registered: 2017-12-14
Posts: 81

Re: iTunes: Add track to beginning/top of specified playlist?

Have a look at the iTunes dictionary.   

For most things it uses "INDEX"


index    integer    The index of the item in internal application order.

and it says it's inherited from ITEM

also check out https://dougscripts.com/itunes/index.php
super great source for info.
Look under the miscellaneous parts and examples code.

hmmm after further reading you might not be able to as it says the index is only available
via get.

What you might have to do is
- make a new temporary playlist in applescript.
- duplicate the track you want 1st to it
- duplicate the rest of the other playlist to it
- then either deal with having a new playlist

OR
- create an array and add your new 1st track to it
- add the tracks from the other playlist
- remove the tracks from the other playlist
- add the tracks from your array back into to the playlist


also maybe investigate the fixed indexing property of your playlist

also try
"front"
"before item 1 of"
"index 1 of"

Offline

 

#3 Yesterday 11:15:48 am

Jono
Member
Registered: 2008-07-08
Posts: 95

Re: iTunes: Add track to beginning/top of specified playlist?

That's great, thanks a lot. Lots of things to look at and try there smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)