Import Video's into iTunes with apple script an set video kind
I'm working on an apple script that you can drop files on and it will open Quicktime, save the file(s) as a self contained .mov and then add the new .mov file(s) to iTunes.
The part I'm not able to get working is setting the video kind after adding the file.
How to you select the track(video) you just imported into itunes and define meta data?
Here is the main part of the code:
tell application "QuickTime Player"
run
open the_mov
if (can export front document as QuickTime movie) then
repeat
if ((get load state of front document) = complete) then
try
save self contained front document in (new_file & ".mov")
close document 1
tell application "iTunes"
if media_type is "Movie" then set media_type to movie
if media_type is "Music Video" then set media_type to music video
if media_type is "TV Show" then set media_type to TV show
launch
add (new_file & ".mov")
set sel to selection
set video kind of sel to media_type
end tell
exit repeat
on error the_error
if the_error is "A file by that name already exists." then
set new_file to (new_file & " - 1") as string
else
activate
display dialog the_error giving up after 30
exit repeat
end if
end try
end if
end repeat
else
display dialog "QuickTime is not able to convert this file: " & (get name of (info for thisItem without size)) buttons "Ok" default button 1 with icon caution
end if
end tell
The part I'm not able to get working is setting the video kind after adding the file.
How to you select the track(video) you just imported into itunes and define meta data?
Here is the main part of the code:
tell application "QuickTime Player"
run
open the_mov
if (can export front document as QuickTime movie) then
repeat
if ((get load state of front document) = complete) then
try
save self contained front document in (new_file & ".mov")
close document 1
tell application "iTunes"
if media_type is "Movie" then set media_type to movie
if media_type is "Music Video" then set media_type to music video
if media_type is "TV Show" then set media_type to TV show
launch
add (new_file & ".mov")
set sel to selection
set video kind of sel to media_type
end tell
exit repeat
on error the_error
if the_error is "A file by that name already exists." then
set new_file to (new_file & " - 1") as string
else
activate
display dialog the_error giving up after 30
exit repeat
end if
end try
end if
end repeat
else
display dialog "QuickTime is not able to convert this file: " & (get name of (info for thisItem without size)) buttons "Ok" default button 1 with icon caution
end if
end tell
Mac OS X (10.5.4), Applescript iTunes