Photos import failed in automator

Hey there,


I am trying to import images from a folder automatically in the Photos app by using automator. The problem is: Photos app is always crashing when doing this action.


User uploaded file


The error basically says: Script "Import files in photos" failed


Why? Somebody having this problem?

Due to this generic error message I have no idea how to solve this.

(Images are taken with iPhone 6S and importing manually by drag and drop works well)


Thanks!

MacBook Pro (13-inch, 2017, 4 TBT3), iOS 11.0.3

Posted on Oct 16, 2017 11:47 PM

Reply
11 replies

Oct 17, 2017 3:38 AM in response to sebastianm23

Is this an Automator problem, when you are having the same issue?

There is definitely a buggy behavior, if the error message is always shown, even if the items have been imported correctly.


But if you are seeing the error message, when the images have not been imported correctly, some of your images may have an incompatible format or a corruption. Can you try to find out, which images are causing this error? try to check, which photo would have been he next to be imported, by comparing the files, that could be imported to the files that did not import.

Nov 27, 2017 4:03 AM in response to sebastianm23

In the time since you first reported your issue to the community, you may very well have found alternative means to meet your objective.

As others have clarified, the Automator process crashes when attempting to import photos into Photos.app using the Add to Album action. Photos are imported, however the workflow cannot continue beyond this action.

In case you might still need a workaround, AppleScript can be used instead, and also gives the added benefit of being able to import photos into any album in Photos.app rather than being limited to a top-level album.

--on adding folder items to ImportFolder after receiving SomeFiles


--Allowable file types imported by Photos.app:

--The ones preceded by a dash are importable, but are probably less

--likely to be wanted and won't be imported after they are filtered

--out below.
Remove the dash to permit importing of these filetypes.

set AppleScript'stext item delimiters to " "

set AllowedExtensions to "jpeg jpg tiff tif png gif heic heif -pdf " & ¬

"raw dng mov -qt -avi -vfw -mpg -mpeg mp4 mp4v m4v " & ¬

"-3gp -3gpp -3g2 -3gp2 -3gpp2"



--The variables ImportFolder and SomeFiles are defined either

--explicitly by the the following two variable declarations, or implicitly

--by the event handler above.
Comment in/out as appropriate.

set ImportFolder to POSIX file "/Path/To/Camera/Uploads" as alias

tell application "Finder" to set SomeFiles to files of ImportFolder


if number of SomeFiles is 0 then ¬

return 0



--Set the album into which media will be imported.
Leave it

--empty to import the photos without putting them into an album.

--If the album name doesn't contain any meaningful characters or

--isn't unique, the photos will be imported without being placed in

--an album.

set AlbumName to "Kameraimporte"



--The files in the import folder are filtered by file extension

set MediaFiles to {}

repeat with TheFile in SomeFiles

tell application "Finder" to tell TheFile to ¬

if its name extension is in ¬

(text items of AllowedExtensions) then ¬

set end of MediaFiles to it as alias

end repeat

if number of MediaFiles is 0 then ¬

return 0


--The Photos application is opened in the background and

--the media files are added to the designated album.

tell application "Photos"

try

with timeout of 120 seconds

run--Prevents the app from coming into the foreground

end timeout

delay 2

on error

return -1

end try


--Files are imported.
They are not placed in an album yet

set MediaItems to (importMediaFiles with skip check duplicates)


--Once imported, the Finder files can be deleted

tell application "Finder" to deleteMediaFiles


--If no album name or no unique album name was specified above

--then the script if finished.
It returns the number of new media

--items added to the Photos library.

if (countwords in AlbumName) = 0 or ¬

(count (albums whose name is AlbumName)) > 1 then ¬

return number of MediaItems


--If a unique album name is specified, then the album is created

--if it does not yet exist, and the imported media items are added

--(copied) into the album.
The script returns the number of new

--library imports.

tell (albumnamedAlbumName)

if not (it exists) then makenewalbumnamedAlbumName

addMediaItemsto it

return number of MediaItems

end tell


end tell

--end adding folder items to

The script will work as a standalone script in its current form, or as part of an Automator workflow using the Run AppleScript action.
The first and final lines that are commented out can be uncommented in order to create a folder action script that will run each time whichever folder it is attached to receives new files (be sure to comment out the explicit variable declarations for ImportFolder and SomeFiles if these variables are being defined as part of the event handler in the first line).


This script is a modified version of the one I’ve been using for a couple of months, and it seems to work reliably thus far.



CK

Oct 17, 2017 12:21 AM in response to léonie

I tested importing with the same workflow you are showing in your screenshot on the current version of High Sierra.

The workflow is showing the same error message as you are showing, but all photos are imported correctly from the folder. Are your photos also imported correctly?


Perhaps the error message is just bogus and Automator interprets the returned result of the last action incorrectly.


The problem is: Photos app is always crashing when doing this action.

Photos on High Sierra does not crash for me, even if the Automator workflow is signaling this error. Are you running your workflow as a service from inside Photos?

Oct 17, 2017 10:14 AM in response to sebastianm23

The photos are shot with iPhone 6S - so why should they be incompatible? If I drag and drop them in the photos app it works without any problems.

Your iPhone photos are compatible, no problem. But there might be a transmission error causing a photo corruption when importing from the iPhone. Or you might have saved some photos to your camera roll, downloaded from a web page. That is the most common reason for problems when importing from an iPhone. Or if you have been using a third party camera application on the iPhone.


If this is indeed an issue with Automator, is there a way to contact Apple to solve this buggy behavior?

You can use the feedback form to submit a bug report.

https://www.apple.com/feedback/photos.html

Oct 18, 2017 3:07 AM in response to léonie

I tested different cases and right now the import seems to work proberly for images which I imported over 'Digital Images App'. The result is, I have 2 files - the image and the .mov files (Live Photo). Before that I synced the files over a private cloud.

The Automator process is still crashing, but the images where imported anyway in all cases.


Now, since the Automator cannot do any following actions after crashing, I need a new Automator process afterwards to delete the images from Finder. This process need to be delayed to avoid that images are deleted before being imported. I will report how this works.

Oct 22, 2017 8:11 AM in response to sebastianm23

Well, not a solution, but a hint for the problem source. I have recently created an Automator App to import jpegs to “Photos“ after the export from Adobe Lightroom has finished, and to delete the export folder ounce the pictures are imported in Photos.


It worked perfect, until yesterday, when I upgraded to „High Sierra“ (language settings: German). I am getting the same error message, the pictures are perfectly imported to “Photos“, but the Automator stops and doesen‘t finish it‘s job (...to delete the export folder). Even a new Automator App only for the „Photos import“ results in the same bug.


Conclusion: a High Sierra bug. Hope they correct this soon.

Oct 17, 2017 2:50 AM in response to léonie

I have the newest version High Sierra 10.13.


The first step in the workflow is "Find object in Finder" (in a specific folder). Not sure how this is named in English.


Sometimes the error pops up in between - This means the import is not finished and also won't continue after this error.

Therefore I cannot rely on this.

Also I'd like to move the imported images from this folder to the bin afterwards, since they are saved in the Photos library. Due to the stopped workflow, this step won't be executed.


Is this an Automator problem, when you are having the same issue?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Photos import failed in automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.