如何使用Applescript将图片导入Photos.app
我使用上面的脚本将一张图片导入照片,但照片在运行时显示错误“无法获取元数据”。我的脚本怎么了,有人知道如何将一张图片导入照片吗 [编辑] 我找到了正确的方法如何使用Applescript将图片导入Photos.app,applescript,Applescript,我使用上面的脚本将一张图片导入照片,但照片在运行时显示错误“无法获取元数据”。我的脚本怎么了,有人知道如何将一张图片导入照片吗 [编辑] 我找到了正确的方法 set oldPath to "/Users/user/Desktop/aaaa/1110.jpg" set thisPOSIXPath to (the POSIX path of oldPath) set imageList to {} copy thisPOSIXPath to the end of imageList tell
set oldPath to "/Users/user/Desktop/aaaa/1110.jpg"
set thisPOSIXPath to (the POSIX path of oldPath)
set imageList to {}
copy thisPOSIXPath to the end of imageList
tell application "Photos"
import imageList into container named "MyPictures"
end tell
Photos.app需要一个别名说明符列表作为导入命令的参数
桌面路径
是当前用户桌面文件夹的相对路径。as text
将别名说明符强制为HFS路径(冒号分隔)。在大括号
{}
中包装对象会将对象强制为列表
set filePath to POSIX file "/Users/user/Desktop/aaaa/1110.jpg"
set imageList to {}
copy filePath to the end of imageList
repeat with i from 1 to number of items in imageList
set this_item to item i of imageList as alias
end repeat
tell application "Photos"
import imageList into container named "MyPictures"
end tell
set filePath to alias ((path to desktop as text) & "aaaa:1110.jpg")
tell application "Photos"
import {filePath} into container named "MyPictures"
end tell