iTunes geting info and repeat for each.

I am having truble geting song info (specifically artist and title) for each song in a selection and it needs to repeating for each song.

anyone who contributes will get their name added to the list of developers when the final freewear project is finished.
thanks alot!

this is the script so far it gets artist and song name for the currently playing song and fetches the songs DNA from pandora and puts it in the songs comments.


(* this project is copyright FIREstorm PCs 2010
[url=http://www.firestormpcs.net]www.firestormpcs.net[/url] *)
tell application "iTunes"
	set trck to current track
	set title_text to "Now Playing"
	set song_pre to name of trck
	set artist_pre to artist of trck
	set oldcomments to comment of current track
	
end tell

if oldcomments contains "Pandora Music Genome Tags: " then
	
else
	findAndReplace(" ", "+", artist_pre, song_pre)
end if
findAndReplace(" ", "+", artist_pre, song_pre)
on findAndReplace(tofind, toreplace, TheString1, TheString2)
	--TheString1 --> res1
	set ditd to text item delimiters
	set text item delimiters to tofind
	set textItems to text items of TheString1
	set text item delimiters to toreplace
	if (class of TheString1 is string) then
		set res1 to textItems as string
	else -- if (class of TheString is Unicode text) then
		set res1 to textItems as Unicode text
	end if
	set text item delimiters to ditd
	set artist to res1
	
	--TheString2 --> res2
	set ditd to text item delimiters
	set text item delimiters to tofind
	set textItems to text items of TheString2
	set text item delimiters to toreplace
	if (class of TheString2 is string) then
		set res2 to textItems as string
	else -- if (class of TheString is Unicode text) then
		set res2 to textItems as Unicode text
	end if
	set text item delimiters to ditd
	set song to res2
	
	
	--set artist to "infected+mushroom"
	--set song to "converting+vegetarians"
	try
		do shell script ("curl [url=http://www.pandora.com/music/song/]http://www.pandora.com/music/song/"[/url] & artist & "/" & song & "")
	end try
	
end findAndReplace
--try
set page to result


split(page, "Features Of This Song", "</div>", "These are just a few of the", "<br>", ", ")
--> {"This", "is", "a", "text"}
--end try
to split(someText, delimiter1, delimiter2, delimiter3, delimiter4, delimiter5)
	
	--	try
	set AppleScript's text item delimiters to delimiter1
	set step1 to someText's text item 2
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	
	set AppleScript's text item delimiters to delimiter2
	set step2 to step1's text item 2
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	
	set AppleScript's text item delimiters to delimiter3
	set step3 to step2's text item 1
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	
	
	set AppleScript's text item delimiters to delimiter3
	set step4 to step3's text item 1
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	
	
	set AppleScript's text item delimiters to delimiter3
	set step5 to step4's text item 1
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	
	set ditd to text item delimiters
	set text item delimiters to delimiter4
	set textItems to text items of step5
	set text item delimiters to delimiter5
	if (class of step5 is string) then
		set step6 to textItems as string
	else -- if (class of TheString is Unicode text) then
		set step6 to textItems as Unicode text
	end if
	
	set text item delimiters to ditd
	set ditd to text item delimiters
	set text item delimiters to "	"
	set textItems to text items of step6
	set text item delimiters to ""
	if (class of step6 is string) then
		set res1 to textItems as string
	else -- if (class of TheString is Unicode text) then
		set res1 to textItems as Unicode text
	end if
	set text item delimiters to ditd
	return res1
	
	--	end try
	
end split
set fin to result

--> place text in a single line
set textList to paragraphs of fin
set oneLine to ""
repeat with i from 1 to count of textList
	if (item i of textList) is not "" then
		set oneLine to oneLine & removeLeadingAndTrailingSpaces(item i of textList) & space
	end if
end repeat
set oneLine to text 1 thru -2 of oneLine

on removeLeadingAndTrailingSpaces(theString)
	repeat while theString begins with space
		if (count of theString) is greater than 1 then
			set theString to text 2 thru -1 of theString
		else
			exit repeat
		end if
	end repeat
	
	repeat while theString ends with space
		if (count of theString) is greater than 1 then
			set theString to text 1 thru -2 of theString
		else
			exit repeat
		end if
	end repeat
	return the theString
end removeLeadingAndTrailingSpaces
set theString_fin to result

tell application "iTunes"
	set newline to ASCII character 10
	
	set comment of current track to ("Pandora Music Genome Tags: " & newline & theString_fin) as string
	return ("Pandora Music Genome Tags: " & newline & theString_fin) as string
	
end tell