将文件移动到不同文件夹时出现Applescript错误-1728

问题描述 投票:0回答:1

我正在尝试使用 AppleScript 将预览中当前查看的文件(在我的案例图像中)移动到另一个文件夹。想法是使用此 AppleScript 创建一个快捷方式,以轻松浏览我的图像并对它们进行排序。

我收到错误 1728“文件无法读取”。

tell application "Preview" to set thefile to path of front document


tell application "Finder"
    set p to "Users:XXX:XXX:XXX:Favoriten"
    set favorit to POSIX path of p
    move POSIX file thefile to favorit with replacing
end tell
applescript
1个回答
0
投票

这里有一些值得尝试的事情。一般来说,使用系统事件移动文件有很多优点,尤其是速度。

这里一个有用的怪癖是系统事件似乎会自动处理文件的路径。

tell application "Preview" to set pef to path of front document
--> "/Users/user/Downloads/usage/abc123.jpg"

set dst to (path to home folder as text) & "Desktop:desto:"

tell application "System Events"
    
    move file pef to folder dst
    --> file "MacHD:Users:user:Desktop:desto:abc123.jpg" of application "System Events" 
    
end tell
© www.soinside.com 2019 - 2024. All rights reserved.