Re: iphoto
Re: iphoto
- Subject: Re: iphoto
- From: kai <email@hidden>
- Date: Wed, 8 Jun 2005 02:41:48 +0100
On Monday, June 6, 2005, at 06:24 pm, Ruby Madraswala wrote:
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.
Something like <alias "Macintosh HD:Ruby:images:"> or <"Macintosh
HD:Ruby:images:" as alias> *should* work, Ruby - as long as the quoted
path is a valid one. It might help if you try running this snippet...
-----------------
set the clipboard to "set this_item to alias \"" & (choose folder) &
"\""
-----------------
...and then (without copying anything) paste into your script.
I also see that you're trying to import images into iPhoto using UI
scripting. You'll probably have fewer headaches if you make a direct
call to iPhoto - as shown in the example below. The script is
configured so that, if you choose a folder, you'll be given the option
of using that folder's name to make a new album (provided, of course,
that an album of that name doesn't exist already).
-----------------
to chooseSource()
if (display dialog "Import an image file or a folder of images?"
buttons ¬
{"Cancel", "Folder", "Image"} default button 3)'s button returned is ¬
"Image" then return {choose file of type {"JPEG"} with prompt ¬
"Choose an image to import:", ""}
set f to choose folder with prompt "Choose a folder of images to
import:"
{f, (info for f)'s name}
end chooseSource
to chooseAlbum for sourceName
tell application "iPhoto" to set albumList to name of albums
set newAlbum to (count sourceName) > 0 and ¬
sourceName is not in albumList
if newAlbum then set albumList's end to sourceName
tell (choose from list albumList with prompt ¬
"Choose an album:" default items {sourceName})
if it is false then error number -128
set chosenAlbum to item 1
end tell
tell application "iPhoto"
if chosenAlbum is sourceName and newAlbum then ¬
new album name chosenAlbum
select album chosenAlbum
end tell
end chooseAlbum
set {sourceItem, sourceName} to chooseSource()
set targetAlbum to chooseAlbum for sourceName
tell application "iPhoto" to import from sourceItem to targetAlbum
-----------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >iphoto (From: "Ruby Madraswala" <email@hidden>) |