I’m trying to edit a selected mpg movie in iphoto, rotate it, and replace it.
I’ve hobbled together this script but it doesn’t seem to do anything.
I put the output to an editmovie folder because I was unsure how to get it back into iphoto since the file naming system is complicated.
tell application "iPhoto"
set added_Items to selection
end tell
set thisFolder to (path to movies folder as Unicode text) & "editmovie:" as alias
on adding folder items to thisFolder after receiving added_Items
tell application "QuickTime Player"
repeat with theFile in added_Items
if name extension of (info for theFile) is "mpg" then
set NewFile to text 1 thru -5 of (theFile as string) & ".mov"
open theFile
tell front movie
stop
rotate right
with timeout of 500 seconds
save self contained in NewFile
end timeout
close
end tell
end if
end repeat
end tell
end adding folder items to
the whole thing is complicated.
The image path property of the movie in iPhoto points to an .jpg image in the Modified part of the library.
The movie file is in the corresponding folder of the Originals part. The filename is the property name or title of the movie.
The following script does everything you described execpt it saves the rotated movie in the same folder as the original (where your variable NewFile points to)
and it does not rename the file in iPhoto. But I hope, it helps you a bit
tell application "iPhoto"
set added_Items to selection
end tell
set thisFolder to (path to movies folder as Unicode text) & "editmovie:" as alias
-- on adding folder items to thisFolder after receiving added_Items
repeat with theFile in added_Items
tell application "iPhoto" to set {thePath, theName} to {(POSIX file (get image path of theFile)) as alias, name of theFile}
set {TID, text item delimiters} to {text item delimiters, ":"}
tell text items of (thePath as Unicode text) to set thePath to (items 1 thru 5 & "Originals" & items 7 thru -2 & theName) as Unicode text
set text item delimiters to TID
if name extension of (info for thePath as alias) is "mpg" then
set NewFile to text 1 thru -5 of thePath & ".mov"
tell application "QuickTime Player"
open thePath
tell front movie
stop
rotate right
with timeout of 500 seconds
save self contained in NewFile
end timeout
close
end tell
end tell
end if
end repeat
-- end adding folder items to
Note: I commented out the folder action handler, because it doesn’t work anyway with this syntax.
A selection in iPhoto contains photo (elements) of iPhoto, not just paths
The path should be File BlueLagoon:Glass Pictures:iPhoto Library:Modified:2007:Originals:Roll 502:MOV00722.MPG.
I don’t know, where the folder MOV00722.jpg comes from
I guessed that, but in your path above it’s also a folder and this shouldn’t be unless you created a folder “MOV00722.jpg” …Roll 502:MOV00722.jpg:MOV00722.MPG means file “MOV00722.MPG” of folder “MOV00722.jpg” of folder “Roll 502”…
ok, I adjusted a few things and it works fine except I want to import it back into iphoto.
Do I need to make another jpeg file for the new movie or can i use the import command similar to the one below.
I haven’t been able to make it work and I"m not sure why? I get a message that
. and it does not recognize Newfile as a path.
tell application "iPhoto"
set added_Items to selection
end tell
-- on adding folder items to thisFolder after receiving added_Items
repeat with theFile in added_Items
tell application "iPhoto" to set {thePath, theName} to {(POSIX file (get image path of theFile)) as alias, name of theFile}
set {TID, text item delimiters} to {text item delimiters, ":"}
tell text items of (thePath as Unicode text) to set thePath to (items 1 thru 3 & "Originals" & items 5 thru -2 & theName) as Unicode text
set text item delimiters to TID
if name extension of (info for thePath as alias) is "MPG" then
set NewFile to text 1 thru -5 of thePath & ".mov"
tell application "QuickTime Player"
open thePath
tell front movie
stop
rotate right
with timeout of 500 seconds
save self contained in NewFile
end timeout
close
end tell
end tell
tell application "iPhoto" to import files from NewFile without force copy
end if
end repeat