2015-01-20 62 views
0

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

我只需要将文件从〜/ Downloads/blank.potx移动到〜/ Library/Application Support/Office /用户模板/我的模板

这是我在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 

同样,使用苹果的第一天脚本和我迷路了。任何你能提供的帮助都会很棒。

如果有更好的方法来做到这一点,请让我知道。

谢谢!

回答

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文件路径,你需要指出的话,你需要命名字符串作为文件。

+0

此(官方)文档概述了AppleScript中可用的各种(以及许多)文件参考。它应该很容易,但事实并非如此。不同的命令需要不同的文件参考形式一些(体面建造的)可以接受各种形式,但是你仍然必须遵循各种惯例来区分彼此。 https://discussions.apple.com/docs/DOC-6681 – brennanyoung 2015-01-21 14:29:46