I'm trying to automate the process of importing photos onto a Mac remotely.
The Mac has remote access to the images, e.g. via ssh the machine is accessed and mounts the remote filesystem containing the images to import.
So far I have run into nothing but trouble. First I ran into this:
execution error: Photos got an error: Application isn’t running. (-600)
I found this question which suggested that the machine be rebooted. That fixed this issue, but did not inspire confidence that a reboot will not be needed an inopportune times in the future.
After rebooting, I got a new error:
An error of type -10810 has occurred. (-10810)
My searches turned up nothing useful, but finally after I went and logging in to the console this error went away. Not being able to do anything remotely without the user logged at the console isn't a show stopper at the moment, but it may be in the future when console access isn't available.
Next I got this error:
execution error: Photos got an error: AppleEvent timed out. (-1712)
After going back to the console I discovered it had popped up an error message and was waiting for somebody to dismiss it. Not helpful to have an automation tool that doesn't actually automate everything!
The error dialog that popped up said:
none of these files can be imported into your photos library
The command I ran was:
osascript -e 'tell application "Photos" to import "DSC_0312.JPG"'
Where DSC_0312.JPG
was a valid JPEG file, which obviously is something that can be imported!
I tried to search for the exact format of the arguments to the "import" verb but was not able to find any using Google. I did find some example scripts which suggested I need to import "into" something. I just want the result to be the same as if I do an import in iPhoto itself. In such a case the images just go into "All Photos" and "Last Import".
I have tried several things but none of them works:
$ osascript -e 'tell application "Photos" to import { "DSC_0312.JPG" } into "All Photos"'
29:72: execution error: Photos got an error: Can’t make "All Photos" into type album. (-1700)
$ osascript -e 'tell application "Photos" to import { "DSC_0312.JPG" } into "Last Import"'
29:73: execution error: Photos got an error: Can’t make "Last Import" into type album. (-1700)
$ osascript -e 'tell application "Photos" to import { "DSC_0312.JPG" } into (album "All Photos")'
29:80: execution error: Photos got an error: Can’t get album "All Photos". (-1728)
$ osascript -e 'tell application "Photos" to import { "DSC_0312.JPG" } into (album "Last Import")'
29:81: execution error: Photos got an error: Can’t get album "Last Import". (-1728)
$ osascript -e 'tell application "Photos" to import { "DSC_0312.JPG" } into container "All Photos"'
29:82: execution error: Photos got an error: Can’t get container "All Photos". (-1728)
$ osascript -e 'tell application "Photos" to import { "DSC_0312.JPG" } into container "Last Import"'
At this point it hangs again until I go back to the remote machine only to find this message blocking the screen again:
none of these files can be imported into your photos library
Update:
If I import directly from Photos and navigate to the same file, the import succeeds, so the file is definitely good. However, I notice that despite navigating to the mount point for the remote file, the Finder magic is showing a completely different path e.g. relative to smb://...
instead of the path in the filesystem that the mount point exists at.
So I tried this:
osascript -e 'tell application "Photos" to import { "smb://MEM/d/Library/Images/DSC_0312.JPG" } into container "Last Import"'
and still get:
none of these files can be imported into your photos library