Import to multiple iPhoto libraries

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Import to multiple iPhoto libraries Thu Jan 31, 2008 11:35 am • by crand1
I apologize if this has already been covered elsewhere.

I am trying to use two folders ("Business" and "Home") where I will drop pictures. I would like to use Hazel to automatically import pictures deposited in the Business folder to my Business library in iPhoto, and import the pictures deposited in the Home folder to my Home library in iPhoto.
crand1
 
Posts: 2
Joined: Thu Jan 31, 2008 11:26 am

Thu Jan 31, 2008 4:53 pm • by Mr_Noodle
Are you referring to albums or libraries? If albums, as long as the album exists already, it should be selectable in Hazel's "Import into iPhoto" action.

If you mean separate libraries then I need some more clarification as I'm unfamiliar with this type of setup.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thu Jan 31, 2008 6:43 pm • by crand1
Mr_Noodle wrote:Are you referring to albums or libraries? If albums, as long as the album exists already, it should be selectable in Hazel's "Import into iPhoto" action.

If you mean separate libraries then I need some more clarification as I'm unfamiliar with this type of setup.


I mean multiple libraries. You can select a library by holding down the Option key while opening iPhoto. You can then click Choose Library and pick from the list of available libraries.
crand1
 
Posts: 2
Joined: Thu Jan 31, 2008 11:26 am

Fri Feb 01, 2008 1:20 pm • by Mr_Noodle
I don't think it's possible at the moment. Hazel imports into iPhoto by asking iPhoto to import the files. If I understand it correctly, iPhoto only sees that one library while it's running so there's no way to get it to switch libraries on the fly. It just uses whatever library was selected on startup.

I don't know if it's possible to automate that start up selection using AppleScript and even if you do that, it might be a bit clunky. Unfortunately, I can't think of any other way to do it at the moment. Sorry.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Import to multiple iPhoto libraries Mon Nov 29, 2010 7:39 pm • by gcoghill
I too would like to be able to do this. With iPhoto '09, you can double-click on an iPhoto Library to open it, however Hazel has iPhoto libraries grayed out when I attempt to open one with the "Open file" action.

I found an AppleScript to open up a specific iPhoto Library, however when I run it it brings up the iPhoto '09 "Library chooser" window which puts a halt to any automation.

If we could just get Hazel to allow opening of the iPhoto '09+ library files, that would be ideal. Otherwise, perhaps some AppleScript guru could shed some light on how to modify that script so we can bypass the "Library chooser" window.

Here's the AppleScript for easy reference:
Code: Select all
--http://maeks84.wordpress.com

property libraryPath : "Macintosh HD:User:File:Path:To:iPhoto Library"

--Determine if iPhoto is open and needs to be quit
--Will only bring iPhoto to the front if the correct library is already open
tell application "System Events"
   if exists process "iPhoto" then --Only worries about the current user
      tell application "iPhoto"
         if image path of photo 1 does not contain POSIX path of libraryPath then
            activate
            beep
            display dialog "About to quit iPhoto!" giving up after 60 --Gives a chance to cancel otherwise continues on
            quit
            tell application "System Events"
               repeat while exists process "iPhoto"
                  delay 3
               end repeat
            end tell
            my launch_library()
         else
            activate
         end if
      end tell
   else --iPhoto is not currently running
      my launch_library()
   end if
end tell

on launch_library()
   do shell script "defaults write com.apple.iPhoto RootDirectory " & quoted form of POSIX path of libraryPath
   tell application "iPhoto" to activate
   tell application "System Events"
      repeat while (exists process "iPhoto") is false --Delay until iPhoto is launched
         delay 5
      end repeat
   end tell
   do shell script "defaults remove com.apple.iPhoto RootDirectory" --Restore the default library
end launch_library
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Re: Import to multiple iPhoto libraries Tue Nov 30, 2010 1:28 am • by gcoghill
The original author of that AppleScript kindly helped me through this problem. The issue was that I did not have a default library specified with iPhoto (not sure how that happened). As long as you have a default library specified, this should do the trick.

See the link above for our comment thread, I had an additional issue where my default iPhoto library was not stored in the default OS X location (I have it on an external drive). The script author walked me through it in the comments on that post.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Re: Import to multiple iPhoto libraries Tue Nov 30, 2010 1:48 am • by gcoghill
Hmm, Hazel is giving me an error when I try to run that external AppleScript when a specified folder has been modified (new photos added):

"AppleScript failed: Error executing AppleScript iPhoto Library Launcher.scpt on file photos temp." ("photos temp" being a folder)

I dont want to run the AppleScript on the file, I just want the AppleScript to run. How do I do this? The AppleScript runs fine if I don't route it through Hazel. Basically I want Hazel to run that script to switch iPhoto libraries if the folder has been modified, then dig into the folder and add the images with a specific color label to an album in iPhoto. Then mark the images with a different color label so they don't get re-processed.

Ideally it would then quit iPhoto after doing so, but I haven't gotten that far yet.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Re: Import to multiple iPhoto libraries Tue Nov 30, 2010 11:59 am • by Mr_Noodle
I believe that's just a generic error message. You can ignore the file argument passed in. There should be a more specific error logged. Post that if you can find it.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Import to multiple iPhoto libraries Tue Nov 30, 2010 12:11 pm • by gcoghill
Here's the error in the Console:
Code: Select all
2010-11-30 11:10:07.890 hazelfolderwatch[36991] [Error] AppleScript failed: Error executing AppleScript /Users/George/Library/Scripts/iPhoto Scripts/iPhoto Library Launcher.scpt on file /Users/George/Desktop/_temp stuff [folders]/photos misc temp.
2010-11-30 11:10:07.890 hazelfolderwatch[36991] AppleScript error: {
    OSAScriptErrorNumberKey = -1708;
}
 
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Re: Import to multiple iPhoto libraries Tue Nov 30, 2010 12:15 pm • by Mr_Noodle
Is this in an external script? If so, you need to add a handler around the code (see the help).

If this is embedded, it probably won't work as it defines its own handlers and you can't nest them (embedded scripts have are actually contained within an implicit handler).
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Import to multiple iPhoto libraries Tue Nov 30, 2010 12:54 pm • by gcoghill
Darn it, that handler code is going to be the death of me. Yes, it is external and adding the handler code cleared it right up! Thanks once again, been wanting to figure out how to automate this for some time, and now the bulk of the work is done for this one.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH


Return to Support

cron