如何完全自动化将图像导入照片

时间:2017-04-30 17:41:57

标签: macos ssh applescript

我试图自动将照片远程导入Mac。

Mac可以远程访问图像,例如通过ssh访问机器并安装包含要导入的图像的远程文件系统。

到目前为止,我遇到了麻烦。首先我碰到了这个:

execution error: Photos got an error: Application isn’t running. (-600)

我发现this question表示重启机器。这解决了这个问题,但并没有激发人们相信将来不需要重新启动的信心。

重新启动后,我收到了一个新错误:

An error of type -10810 has occurred. (-10810)

我的搜索没有任何用处,但最后我登录控制台后,这个错误就消失了。如果用户没有在控制台登录,则无法远程执行任何操作现在不会显示停止,但未来可能无法使用控制台访问。

接下来我收到了这个错误:

execution error: Photos got an error: AppleEvent timed out. (-1712)

回到控制台后,我发现它弹出了一条错误信息,正在等待有人解雇它。拥有一台并非真正实现一切自动化的自动化工具没有帮助!

弹出的错误对话框说:

none of these files can be imported into your photos library

我跑的命令是:

osascript -e 'tell application "Photos" to import "DSC_0312.JPG"'

其中DSC_0312.JPG是有效的JPEG文件,显然是可以导入的内容!

我试图搜索" import"的参数的确切格式。动词但无法使用Google找到任何动词。我确实找到了一些示例脚本,建议我需要导入"进入"一些东西。我只想让结果与我在iPhoto中进行导入一样。在这种情况下,图像只会进入"所有照片"和"最后导入"。

我尝试了几件事,但没有一件可行:

$ 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"'

此时它再次挂起,直到我回到远程计算机才发现此消息再次阻止屏幕:

none of these files can be imported into your photos library

更新: 如果我直接从Photos导入并导航到同一个文件,导入成功,所以文件肯定是好的。但是,我注意到尽管导航到远程文件的挂载点,Finder魔术显示了一个完全不同的路径,例如相对于smb://...而不是文件系统中挂载点所在的路径。

所以我尝试了这个:

osascript -e 'tell application "Photos" to import { "smb://MEM/d/Library/Images/DSC_0312.JPG" } into container "Last Import"'

仍然得到:

none of these files can be imported into your photos library

0 个答案:

没有答案