我知道它是一个愚蠢的问题但不知何故我输入的命令不起作用
set deleteFile to srcTemp & "Archive.zip"
--deleteFile path is something like this /Users/home/Desktop/Archive.zip
tell application "Finder"
move POSIX file "" & deleteFile & "" to trash
--move file "\"" & destNoQuote & "Archive.zip\"" to trash
empty the trash
end tell
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,说无法找到POSIX文件.
我知道很多人在Finder告诉代码块中使用posix file命令,但这是一个错误.posix file命令不是Finder命令,它是一个applescript命令,因此如果可能,不应该在Finder块中.实际上对于所有命令都是如此.您应该只告诉应用程序执行您可以在其Applecript字典中找到的命令,否则您将看到意外行为......正如您所发现的那样.
因此,这就是你应该如何编写代码......
set deleteFile to srcTemp & "Archive.zip"
set posixFile to POSIX file deleteFile
--deleteFile path is something like this /Users/home/Desktop/Archive.zip
tell application "Finder"
move posixFile to trash
empty the trash
end tell
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3968 次 |
| 最近记录: |