【问题标题】:Moving a File with AppleScript使用 AppleScript 移动文件
【发布时间】:2015-01-20 20:26:40
【问题描述】:

今天是我知道 AppleScript 存在的第一天,所以如果这是一个愚蠢的问题,我深表歉意。我已经搜索并找不到有关如何使用 AppleScript 简单移动文件的答案

我需要做的就是将文件从 ~/Downloads/blank.potx 移动到 ~/Library/Application Support/Office/User Templates/My Templates

这就是我现在在 AppleScript 中的内容:

tell application "Finder"
     move "~/Downloads/blank.potx" to "~/Library/Application Support/Microsoft/Office/User Templates/My Templates/blank.potx"
end tell

当我运行它时,它给了我一个错误:

error "Finder got an error: AppleEvent handler failed." number -10000

再次,使用 AppleScript 的第一天,我迷路了。你能提供的任何帮助都会很棒。

如果有更好的方法,请告诉我。

谢谢!

【问题讨论】:

    标签: applescript


    【解决方案1】:

    搜索是您的朋友。您可以轻松找到堆栈溢出的语法。如here

    tell application "Finder"
        move POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents/State" with replacing
    end tell
    

    如果您要使用 Posix 文件路径,则需要指明,并且需要将字符串命名为文件。

    【讨论】:

    • 此(官方)文档概述了 AppleScript 中可用的各种(和许多)文件参考。这应该很容易,但事实并非如此。不同的命令需要不同的文件参考形式。一些(体面的)接受所有类型的,但你仍然必须遵循各种约定来区分它们。 discussions.apple.com/docs/DOC-6681
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多