Itunes loop

I’m trying to make a script that will import a track to itunes, put it in its own playlist, allow me to burn it to an audio cd, and then delete the track and playlist. Right now i’m skipping the burning portion. I can import a track add it to a playlist and then delete it, but i can’t modify one variable and line to work in a loop. When i make the script with one track, i play the current track to get the database id. That’s the only way i’ve been able to get it, i can’t seem to get it to work if i tell it to play the track as a variable. I have to use “current track.” However i don’t know how to store or add to dbid so that i can have a list of the dbid(s) to delete at the end.

-- Credit to Doug Adams for script "Quick Convert" for some of the code. My attempts to discover this are shown with he log statements at the end. Help please.

--script to import new file, make the file into a playlist and then delete the playlist and file.

-- try block to check if itunes is active
tell application "iTunes"
	try
		activate
	end try
	display dialog "what is the playlist name" default answer "test" default button 1 giving up after 1
	set test to (text returned of result) as text
	
	--import files into itunes
	
	make new playlist with properties {name:test}
	set this_list to {"Backup:Recordings$:Ray Cano DV:08123456.m4a", "Backup:Recordings$:Ray Cano DV:09123456.m4a"}
	repeat with i from 1 to number of items in this_list
		
		set this_item to item i of this_list
		
		add this_item to playlist test of source "library"
		play this_item
		set dbid to database ID of current track -- problem starts with this line/ variable
		set c_lass to class of current track
		log dbid
		log user playlist id playlist test
		set dbid_list to {dbid as string} --this was my guess at how to proceed
		set dbid_list2 to {dbid, dbid_list} --same, i was trying to get a different value for the variable
	end repeat
	log dbid -- the next three were my attempts to log the variable
	log dbid_list
	log dbid_list2
	log database ID of every track of playlist "test"
end tell


Hi. You don’t need to play a track to obtain an id. I’ve provided my take on how this can be accomplished. All you need to add are your recording steps, and then, optionally, remove library tracks that match a number in the dbid list.

tell application "iTunes"
	if not (exists playlist "test") then make new playlist with properties {name:"test"}
	tell playlist "test"
		set this_list to {"Backup:Recordings$:Ray Cano DV:08123456.m4a", "Backup:Recordings$:Ray Cano DV:09123456.m4a"}
		add this_list to it
		set dbid to tracks's database ID
		--delete--Once you've finished recording or whatever, enable this to be done with the playlist
	end tell
end tell

That made quick work of my mess. Thanks I’ll give it a try.