第09页和applescript,将当前文件保存为.doc并覆盖当前文件

时间:2011-02-01 17:38:09

标签: scripting applescript iwork

我想保存当前打开的文件,因为.doc会覆盖当前文件。 所以我必须找到当前打开的文档路径,然后将当前文件保存在同一路径上,另存为.doc

任何人都可以提供帮助?我在很多方面尝试但总是失败...... (我在OSX 10.6上有第09页)

感谢

1 个答案:

答案 0 :(得分:0)

给它一个旋转:

tell application "Pages" to tell document 1
   set oldname to name
   set oldPath to get path
   try
       set docPath to oldPath
   on error
       set oldPath to (path to documents folder as text) & oldname & ".pages"
       save in oldPath
   end try
   tell application "System Events" to set oldPath to path of disk item oldPath
   if oldPath ends with ":" then set oldPath to text 1 thru -2 of oldPath (* useful is the app saves as packages *)
   set docPath to text 1 thru -(1 + (count of "Pages")) of oldPath & "doc"
   save as "Microsoft Word 97 - 2004 document" in docPath
end tell

来源:MacScripter,所以你可能需要稍微摆弄一下。