Pandoc 多好用啊~但是 Pandoc 只支持 docx,不支持 doc。Win 下这样的工具都是收费的,比较坑。于是小伙伴给了一个不完美的 AppleScript 脚本,通过 Mac 的「Automatic/自动操作」来运行。
首先找到 Automatic,新建一个「工作流程」。最上面搜索「获得指定的访达项目」,拖到右边。然后搜索「运行 Apple Script」,拖到右边,并输入下面一堆咒语:
on run {input, parameters} set the_output to {} tell application "Microsoft Word" repeat with the_file in input try set pdf_path to my makeNewPath(the_file) if not my ifFileExists(pdf_path) then open the_file with read only set the_doc to the active document save as the_doc file format format PDF file name pdf_path close the_doc saving no end if on error error_message number error_number close saving no log ("ErrorMessage: " & error_message & ", ErrorNumber: " & error_number) end try end repeat end tell return the_output end run on makeNewPath(f) set d to f as string if d ends with ".docx" then return (text 1 thru -5 of d) & "pdf" else if d ends with ".doc" then return (text 1 thru -4 of d) & "pdf" else if d ends with ".pdf" then return d else return d & ".pdf" end if end makeNewPath on ifFileExists(f) tell application "System Events" if exists file f then return true else return false end if end tell end ifFileExists
先点击,看看有没有错误。然后将所需要的 doc 文件拖到「获得指定的访达项目」里面,最后点击最右上角的「运行」。
你会看到一个 Word 窗口开了又关,开了又关……就转换好了。
之所以说「不完美」是因为,如果文档比较乱,有宏啊啥的,脚本会卡住,需要手动点击「不启用宏」。如果 Word 打不开,会报错,这时候也需要手动点击两个「确定」。反正只是省去了人工一个一个转换的麻烦,人还是要盯着看的。
而且速度巨慢。
凑合用吧,总比没有强。