Hi
I am working on a script to copy
all jpg images from folder/subfolder to iphoto. I did get some examples from
the internet. But am still running into some problems. I have tried several different
options but none seem to work. Any suggestions appreciated.
Questions to script below:
1. When I change display
dialog "Import an image file....................." and choose to
set this_item to
"Macintosh HD:Ruby:images:"
then select item i of
this_folder = "M". (adding_folder handler)
I tried set this_item
to "Macintosh HD:Ruby:images:" as alias" does not work.
2. Import_photos does not
work - error at
set value of text
field 1 to this_folder
system event got an
error
NSReceiveEvaluationScriptError:
4
3. Adding_folder_items_to
without the
"display dialog item i of this_folder as text" pastes the same sketch
at each repeat. Tried the delay, same result.
with the display
pastes all the sketches correctly.
select album "jpg
images" does not work. paste the sketches in album selected which is
always "Photo Library".
4.How do I extract folder
name from a path.
SCRIPT:
display dialog "Import
an image file or a folder of images:" buttons Â
{"Cancel",
"Folder", "Image"} default button 3
if the button returned of
the result is "Folder" then
set this_item to
choose folder
else
set this_item to
choose file of type {"JPEG"}
end if
--import_photos(this_item)
of me
adding_folder_items_to(this_item)
of me
on
import_photos(this_folder)
tell application
"System Events"
tell process
"iPhoto"
keystroke
"I" using {command down, shift down}
delay 1
keystroke
"/" using {control down}
tell
window "Import Photos"
tell
sheet 1
set
value of text field 1 to this_folder
click
button 1
end
tell
click
button 1
end tell
end tell
end tell
end import_photos
on adding_folder_items_to(this_folder)
tell application
"Finder"
activate
---number of
files in a folder
set cnt to 0
set flist to
every file in folder this_folder
repeat with
curfile in flist
set cnt to
cnt + 1
end repeat
repeat with i
from 1 to cnt
--display
dialog item i of this_folder as text
select
item i of this_folder
tell
application "System Events"
keystroke
"c" using command down
tell
application "iPhoto"
activate
select
album "jpg images"
end
tell
keystroke
"v" using command down
delay
2
end tell
end repeat
end tell
end adding_folder_items_to
Ruby