PeterPeterPeterPeter wrote:
I think I'm close to the perfect solution, but theres still one error: After editing tracks information and tracks options I need to tell the script to select the imported tracks in the library. Otherwise it hits "cmd+i" at the place I left iTunes (e.g. with a playlist selected,
Ok, this seems to be a bug, in my first script the script took the database id of the imported track, I used it to select the track because the reveal command do nothing on the added file, it seems to be the same problem with the Automator action.
The reveal command can select one track only.
Workaround to select multiple tracks is :
The script create a temporary playlist, add imported tracks to it, select all track (command + "a").
Here is the script :
------------------------
onrun {input}
tell application "iTunes"
setptomakenewuser playlist -- make temporary playlist
repeat with thisTrack in input
set data of artwork 1 of thisTrack to (read (file "Users:admin:Music:Cover:Artwork.png") as picture)
duplicatethisTracktop -- add track to temporary playlist
end repeat
activate
revealp -- select temporary playlist
end tell
mychangeTrackMedia("Hörbuch") --"Audiobook" as media kind (on english system)
endrun
onchangeTrackMedia(t)
tell application "System Events"
tell process "iTunes"
keystroke "a" usingcommand down -- select all tracks in temporary playlist
delay 0.3
keystroke "i" usingcommand down
delay 0.3
tell front window
if not (exists tab group 1) then
click value of attribute "AXDefaultButton" -- close the dialog (accept to modify multiple items)
delay 0.3
end if
tell tab group 1
click radio button 5
delay 0.1
tell pop up button 2
click
delay 0.1
tell menu item t of menu 1 to if exists then
click
else
keystroke return
end if
delay 0.3
end tell
clickradio button 2 --this brings the main information tab to the front to manually edit additional information
end tell
end tell
end tell
end tell
endchangeTrackMedia
------------------------
-
If you import one file at a time, use this :
--------------------------
onrun {input}
tell application "iTunes"
activate
set thisTrack to item 1 of input
set data of artwork 1 of thisTrack to (read (file "Users:admin:Music:Cover:Artwork.png") as picture)
set dataID to database ID of thisTrack
reveal (firsttrackof (firstplaylistwhosespecial kindisMusic) whosedatabase IDisdataID)
mychangeTrackMedia("Hörbuch") --"Audiobook" as media kind (on english system)
end tell
endrun
onchangeTrackMedia(t)
tell application "System Events"
tell process "iTunes"
keystroke "i" usingcommand down
tell front window
tell tab group 1
click radio button 5
delay 0.1
click pop up button 2
delay 0.1
tell menu item t of menu 1 of pop up button 2 to if exists then
click
else
keystroke return
end if
end tell
-- click value of attribute "AXDefaultButton"
-- delay 0.3
telltab group 1 -- this brings the main information tab to the front to manually edit additional information
click radio button 2
end tell
end tell
end tell
end tell
endchangeTrackMedia