2015-01-20 61 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