AppleScript to set video kind of current track to music video

I’m trying to write a script that will set the video kind of the current track in iTunes to music video. I think it has to be done with GUI scripting. I’m fairly new to AppleScript, and very inexperienced with GUI scripting, and I’m having trouble. So far I’ve got the script below.


tell application "iTunes"
	activate
	set currTrackName to the name of the current track
end tell
tell application "System Events" to keystroke "i" using command down
tell application "System Events"
	tell process "iTunes"
		try
			tell tab group 1 of window currTrackName
				click radio button "Options"
				delay 1
				click menu item "Music Video" of menu 1 of pop up button 1 of group 1
			end tell
		end try
	end tell
end tell

It opens the Get Info window and clicks the “Options” tab, but for some reason the pane where the options should be never fills in. If you take focus away from iTunes, it will fill in the pane, but what appears is the default view (ie last selected view) in the Get Info box. It’s a little hard to explain, but it should be clear if you run it yourself. Can anyone figure out what I’m doing wrong or how to get around the problem I’m encountering?
Alternatively, has anyone already written a script that will set the video kind of video tracks to music video (preferably multiple tracks at once)?

In case it matters, I’m running 10.4.3 and iTunes 6.0.1.

Model: 12" Rev. C 1.33 GHz PowerBook
AppleScript: 1.10.3
Browser: Safari 416.12
Operating System: Mac OS X (10.4)

For 1 track:


tell application "iTunes"
		set media kind of current track to music video
end tell

For multiple tracks:


tell application "iTunes"
	set theTracks to tracks of (get current playlist)
	repeat with theTrack in theTracks
		try
			set media kind of theTrack to music video
		end try
	end repeat
end tell

NOTE: block try allows to the second script continue batch process, even if the user has in the playlist.
some audio tracks mixed with movies.