Q: iPhoto - Automator Import Script Improvements
Hi All,
I'm mainly working on Lightroom but uses iPhoto to get a better integration into OS X.
My main issue was syncing both librairies and I came to this with an automator script that I'm proud about. I hope it could help some guys also.
I will detail my script below, but I basically have a Lightroom jpegs export into finder folders and an applescript that import them into iPhoto with correct album name.
I have 3 ideas to improve that workflow but didn't manage to script it.
1) First improvement - don't copy files during import to saves space.
For now, iPhoto is copying the files to the library during import.
I want to improve this script by not copying the files into iPhoto library during import but I didn't manage to do it.
I tried to uncheck the tick box "copy the files to iPhoto library" but it didn't works. Import works but files still copied into iPhoto library...
So, I'm struggling with HD space because I've the photos twice on my hard disk (once in folder, once in iPhoto library)
2) Make a daily check of my photo folder content to launch the script automatically during night if there were some changes.
Something like :
If photofolder content (qty of files) is different than the day before, launch the import process
Else
End if
3) Don't import hidden folder
The "dispense item incrementally" is also scanning hidden folder (e.g : 'album data.xml' folder) that I didn't want to appear into iPhoto library.
I didn't find any option to not scan hidden folders right now.
My workflow in Automator :
Delete current iPhoto library
Create new one
List photos folder with "dispense folder incrementally"
Set folder name as a variable
Import this folder content to new iPhoto album with the above variable as album name.
Loop until dispense folder incrementally is done
Hoping that my post could support some guys who need that kind of workflow and hoping you guys could support my needs!
Regards
Posted on Jun 28, 2014 11:40 AM
Hi,
This worflow verify If the photofolder content (qty of files) is different than the day before.
During import, this script does not copy the images into iPhoto library, if the check box "Copy the files to iPhoto library" is unchecked.
This script does not list hidden folders.
This script import JPEG's files only.
This workflow has been tested on Mavericks only.
Try this:
Open Automator, select 'Application'
Add the 'Run AppleScript' action.
Clear all text in the 'Run AppleScript' action.
Copy/paste this script:
set watchFolder to ("pathToWatchFolder" as POSIX file) as text -- remove 'pathToWatchFolder' in this line and drag/drop your folder between the two double quote.
if watchFolder does not end with ":" then set watchFolder to watchFolder & ":"
set txtFile to watchFolder & ":numberOfFiles.txt"
set n1 to 0
try
set n1 to (read file txtFile) as integer -- the number of files (the day before)
end try
do shell script "/usr/bin/find " & (quoted form of POSIX path of watchFolder) & " -type f | wc -l >" & quoted form of POSIX path of txtFile -- update the number of files in file "numberOfFiles.txt"
set n2 to (read file txtFile) as integer -- the number of files (now)
if n1 is n2 or n2 = 0 then error -128 -- same number of files or no files (this leaves this process immediately).
Important : change the path in the first line of this script.
Add your actions to (Delete current iPhoto library and to Create new one).
Add the 'Run AppleScript' action.
Clear all text in the 'Run AppleScript' action.
Copy/paste this script:
set watchFolder to ("pathToWatchFolder" as POSIX file) as text -- remove 'pathToWatchFolder' in this line and drag/drop your folder between the two double quote.
my getSubFolders({watchFolder})
on getSubFolders(tFolders)
repeat with f in tFolders
tell application "System Events"
tell folder f
set jpegs to (POSIX path of files whose type identifier is "public.jpeg") -- get JPEG's file only
set ListSubF to (path of folders whose visible is true)
set tName to name
end tell
end tell
if jpegs is not {} then my import_To_iPhoto(tName, jpegs)
if ListSubF is not {} then my getSubFolders(ListSubF)
end repeat
end getSubFolders
on import_To_iPhoto(t_Name, theseFiles)
tell application "iPhoto"
repeat while importing is true -- wait if importing
delay 2
end repeat
set alb to new album name t_Name
import from theseFiles to alb without force copy -- 'without force copy': use the advanced preference of iPhoto
end tell
end import_To_iPhoto
Important : change the path in the first line of this script.
Save the workflow..
To make a daily check of your photo folder, You can use a Calendar events (this method is for Mavericks, it may be different on other versions of the OS X):
Open the "Calendar" application.
Create a new event, set the repeat to 'Every Day'.
Set the alert to 'Custom', select "Open File" in the first popup, select "Others" in the second popup and choose your workflow (Application)
Select "One day of event" in the third popup
Change the hour in the field.
Posted on Jun 29, 2014 10:41 AM