iTunes: move playlist to folder, sources view doesn't update

I’m working on a script that moves a playlist into a folder when it’s finished doing some other stuff. The problem is that the view of the sources column doesn’t refresh to show the playlist has moved – that is, the playlist still appears to be at the top level, not in the target folder.

The playlist has in fact moved, but you can only see it after some user intervention like expanding and collapsing a folder. Here’s a trivial example for test purposes:


tell application "iTunes"
	move user playlist "foo" to folder playlist "bar"
	set x to the name of parent of user playlist "foo"
	display dialog "The parent folder is \"" & x & ".\" Please observe your sources column."
end tell

I’ve seen this behaviour in the script I’m working on and another script found over on Doug Adams’ site with which I tested.

Can someone reproduce this? If it’s reproducible, can someone suggest a workaround or fix?

Sorry if this has been covered before: Searching with relevant keywords yielded far too many results to really be sure.

Thanks in advance.

It works that way for me, with iTunes 7.1.1; I can’t think of any workarounds right now.

This works.

tell application "iTunes"
	--activate
	move user playlist "foo" to folder playlist "bar"
	set playlist_ to the name of user playlist "foo"
	set view of browser window 1 to folder playlist "bar"
	make new folder playlist with properties {name:"update"}
	delete folder playlist "update"
	set view of browser window 1 to playlist playlist_
end tell

Yes. It does. Playing with it, I also found that it works without the lines that set the view. So it appears all that’s necessary is the make/delete. Runs quick enough that it’s not even visible.

Thank you!

So it does.

But foo even though it shows up, will only be selected if you have foo selected before you run the script.

tell application "iTunes"
	--activate
	move user playlist "foo" to folder playlist "bar"
	make new folder playlist with properties {name:"update"}
	delete folder playlist "update"
end tell

So if it’s not selected and you want it selected after the script has run then use.


tell application "iTunes"
	--activate
	move user playlist "foo" to folder playlist "bar"
	set playlist_ to the name of user playlist "foo"
	make new folder playlist with properties {name:"update"}
	delete folder playlist "update"
	set view of browser window 1 to playlist playlist_
end tell

I assume though, that you will be doing your move by selection.

Yes. This bit is to be part of a larger script and I’m taking care of what gets selected and/or played in another part. You helped me with one of the last remaining quirks. Thanks again.