Having a little problem with a little iTunes-Script

Hey and hello everybody,

Well to come directly to my problem… I have folowing script which is a modification of an already existing script, which copys songs from a smartplaylist in iTunes to a normal playlist. The script is fine, BUT still have to choose the smartplaylist that I want to copy (the list are already reduced by the script to only smartlists I want to be copied). Now I look for a way to let the script do all work. Ok, first of all, here is the script:

code updated, see below :)

I am now looking for a way to let the script run in a ribbon(=repeating ?) (there are about 10 smartplaylists that need to be copied) to do this for every smartplaylist that matches the following string, "Station - ", in its name.
I need this kinde of script because I build some kind of stations for different genres wih a limit on size. Smartplaylists always need the whole library but my iPod Nano only holds 8gb (while my library is a little heavier). I want the script to run everytime i dock my ipod to my MB (realizing it with Automator and a “Check for Disc-Action” and no auto-syncing in iTunes).

I really am not a pro on AS but I am some kind od try & error guy that has just low-basic undersanding of AS, thats why I am askin for advice :wink: I hope someone can help me out with my little problem. If ther are further question do not hesitat to contact me via ichat (goeste (at) mac (dot) com) or via email.

Thx very much in advance !!!

goeste

I have found a very static way…uhm… I do not like that very much. Here is my - now working - code:

tell application "iTunes"
	-- alle smartlisten abfragen
	set smartlists to {"Station - All", "Station - Audiobook", "Station - Dance Hall/Reggea", "Station - Electronic/House/Dance", "Station - Hip Hop/Rap", "Station - Jazz/Swing", "Station - Pop/Latin/Country", "Station - Punk", "Station - Rock/Alternative", "Station - Ska"}
	repeat with i from 1 to (count every item of smartlists)
		set name_of_smartlist to item i of smartlists
		set source_smartlist to (some user playlist whose smart is true and name is name_of_smartlist)
		-- abfrage ob playlist schon existiert, dann erstellen bzw. leeren
		if (exists (some user playlist whose name is name_of_smartlist and smart is false)) then
			set new_playlist to (some user playlist whose name is name_of_smartlist and smart is false)
			delete (every track of new_playlist)
		end if
		-- kopiere tracks von smartlist zu normaler playlist
		set source_tracks to (get a reference to file tracks of source_smartlist)
		repeat with i from 1 to count file tracks of source_smartlist
			try
				duplicate file track i of source_smartlist to new_playlist
			end try
		end repeat
	end repeat
end tell

Below you see the names of the smartplaylists I want to copy, is there a way to get the names into the {} in automaticly instead of hard-coded?

{"Station - All", "Station - Audiobook", "Station - Dance Hall/Reggea", "Station - Electronic/House/Dance", "Station - Hip Hop/Rap", "Station - Jazz/Swing", "Station - Pop/Latin/Country", "Station - Punk", "Station - Rock/Alternative", "Station - Ska"}

THX for any comments and/or ideas :wink:

goeste

goeste:

Try this:

set all_Station_Smarts to name of every user playlist whose smart is true and name contains "Station -"

Good luck,

it works perfect… THX very much