Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wrldwzrd89

macrumors G5
Original poster
Jun 6, 2003
12,110
77
Solon, OH
Alright, I have the following script, which operates on iTunes tracks that have no ID3 tags, and whose names are numbers:

Code:
tell application "iTunes"
	if selection is not {} then
		set sel to selection
	else
		display dialog "You must select some tracks first..." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
	end if
	
	set oldfi to fixed indexing
	set fixed indexing to true
	
	repeat with aTrack in sel
		set theName to do shell script "cat /Users/wrldwzrd89/Documents/Computers/UNIX/Scripts/VGMix/data/autotags/songname/" & aTrack & ".songname"
		set theArtist to do shell script "cat /Users/wrldwzrd89/Documents/Computers/UNIX/Scripts/VGMix/data/autotags/artist/" & aTrack & ".artist"
		set theAlbum to do shell script "cat /Users/wrldwzrd89/Documents/Computers/UNIX/Scripts/VGMix/data/autotags/album/" & aTrack & ".album"
		tell aTrack
			
			set name to theName
			set artist to theArtist
			set album to theAlbum
			set comment to "www.vgmix.com"
			set genre to "Game"
			
		end tell
	end repeat
	
	set fixed indexing to oldfi
	
	try
		if frontmost is true then display dialog "Done!" buttons {"Thanks"} ¬
			default button 1 with icon 1 giving up after 15
	end try
	
end tell

However, it fails on line 12 with a strange error message, complaining about being unable to convert something of some weird class to string. Anyone know why this isn't working?
 

wrldwzrd89

macrumors G5
Original poster
Jun 6, 2003
12,110
77
Solon, OH
Found the problem, and fixed it. Moving the do shell script stuff inside the tell aTrack block and using name instead of aTrack made it work.

Fixed code, for anyone who wants it:

Code:
tell application "iTunes"
	if selection is not {} then
		set sel to selection
	else
		display dialog "You must select some tracks first..." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
	end if
	
	set oldfi to fixed indexing
	set fixed indexing to true
	
	repeat with aTrack in sel

		tell aTrack
			set theName to do shell script "cat /Users/wrldwzrd89/Documents/Computers/UNIX/Scripts/VGMix/data/autotags/songname/" & name & ".songname"
		        set theArtist to do shell script "cat /Users/wrldwzrd89/Documents/Computers/UNIX/Scripts/VGMix/data/autotags/artist/" & name & ".artist"
		        set theAlbum to do shell script "cat /Users/wrldwzrd89/Documents/Computers/UNIX/Scripts/VGMix/data/autotags/album/" & name & ".album"
			set name to theName
			set artist to theArtist
			set album to theAlbum
			set comment to "www.vgmix.com"
			set genre to "Game"
			
		end tell
	end repeat
	
	set fixed indexing to oldfi
	
	try
		if frontmost is true then display dialog "Done!" buttons {"Thanks"} ¬
			default button 1 with icon 1 giving up after 15
	end try
	
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.