【问题标题】:Can't delete a file via applescript due to path由于路径,无法通过applescript删除文件
【发布时间】:2014-01-17 21:06:16
【问题描述】:

我正在尝试使用单行 Applescript 删除已知目录中的文件 - 但我无法让它识别该目录: osascript -e '告诉应用程序“Finder”删除(文件夹“/Folder1/folder2”的全部内容的文件,其名称为“MyFile.txt”)'

但我收到以下错误:

29:183: execution error: Finder got an error: Can’t get folder "/Folder1/folder2". (-1728)

我也试过了:

osascript -e 'tell application "Finder" to delete (files of entire contents of folder "folder2" of folder "Folder1" whose name is "MyFile.txt")'

但结果相似 - 找不到 Folder1

我希望脚本可以跨计算机工作,所以我不知道磁盘名称是什么。

有人有什么建议吗?

提前致谢!

【问题讨论】:

    标签: applescript


    【解决方案1】:

    试试:

    tell application "Finder" to delete (files of entire contents of folder (POSIX file "/Folder1/folder2") whose name is "MyFile.txt")
    

    【讨论】:

      猜你喜欢
      • 2016-09-27
      • 2016-07-27
      • 2016-02-29
      • 1970-01-01
      • 2023-01-20
      • 2023-02-02
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      相关资源
      最近更新 更多