Tuesday, August 11, 2020

#1 2005-12-31 12:01:34 am

Registered: 2005-12-31
Posts: 4

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"
   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"
           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)

Last edited by mduser63 (2005-12-31 12:03:28 am)

Filed under: iTunes, System



#2 2019-08-11 01:46:05 am

Registered: 2019-03-03
Posts: 1262

Re: AppleScript to set video kind of current track to music video

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
           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.

Last edited by KniazidisR (2019-08-11 01:46:38 am)

Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)