mac 批量doc转pdf

2018-04-29


我是一个懒人
我是一个怕麻烦的懒人
我是一个怕麻烦所以喜欢找捷径的懒人
我是一个怕麻烦所以喜欢找捷径却总会花了更多时间有时还失败的懒人

尼玛同事总是布置很麻烦的事让我做。
比如给我一份word模板,让我把每个人的名字分别套用进去,变成21份word
吐血改好之后告诉我模板有问题,让我再重新修改21份
吐胆汁改好之后告诉我要把每份word转成pdf
oh,屎特!我再也不想打开这21份东西了!

但又不能不改,这可怎么办呢?于是我想到了万能的automator




教程时间到:
首先打开软件:




1、选取工作流程
现在这里是空白的




2、把所有要改格式的word文件选中,拖到空白的地方

把word名字全部模糊了

把word名字全部模糊了



关键一步来了!
一步来了!
来了!

3、变量中搜索“运行Apple script”,拖到右边




讲框框里原有代码全删掉,复制以下代码进去:
property theList : {"doc", "docx"}
 
on run {input, parameters}
          set output to {}
          tell application "Microsoft Word" to set theOldDefaultPath to get default file path file path type documents path
          repeat with x in input
                    try
                              set theDoc to contents of x
                              tell application "Finder"
                                        set theFilePath to container of theDoc as text
 
                                        set ext to name extension of theDoc
                                        if ext is in theList then
                                                  set theName to name of theDoc
                                                  copy length of theName to l
                                                  copy length of ext to exl
 
                                                  set n to l - exl - 1
                                                  copy characters 1 through n of theName as string to theFilename
 
                                                  set theFilename to theFilename & ".pdf"
 
                                                  tell application "Microsoft Word"
  set default file path file path type documents path path theFilePath
                                                            open theDoc
                                                            set theActiveDoc to the active document
  save as theActiveDoc file format format PDF file name theFilename
                                                            copy (POSIX path of (theFilePath & theFilename as string)) to end of output
  close theActiveDoc
                                                  end tell
                                        end if
                              end tell
                    end try
          end repeat
          tell application "Microsoft Word" to set default file path file path type documents path path theOldDefaultPath
 
 
          return output
end run

4、再搜索“移动finder项目”,拖到右边,选择你预设好的文件夹
效果如图




好啦!点击运行!小圈圈转啊转



只花了9.228秒诶!!!比一个一个打开再重新改格式是不是快很多!!!所有的PDF文档都存在了指定的文件夹里!再也不用花宝贵的时间在无聊的事情上面了!

参考文献:
http://www.macx.cn/thread-2025136-1-1.html
http://mac.pcbeta.com/thread-92244-1-1.html
https://discussions.apple.com/thread/3050596?start=0&tstart=0


备注:
开始根据搜到的第一篇文章的方法改,发现总是出现运行错误,并且无法批量修改
第二篇文章告诉我们,是因为office的版本问题导致的
由第二篇文章的链接浏览到第三篇,找到了代码并且复制下来,按照流程运行,果然棒棒的!


特别鸣谢:

我都说了我是一个懒人,自己不想完成的任务当然外包出去...
任务书是这样的:automator可以有效率的完成批量任务,故请用该法将21份word转化成pdf并保存到指定文件夹。
接到这个任务后,我那没摸过mac的码农小男友在连关窗口是哪个颜色的键都不知道的情况下,参考了以上三个网页,按方法5分钟内搞定了任务。当我看到pdf文档整齐的排列在文件夹里,码农小男友矮宅呆的形象在我眼里顿时变得高大上起来了!!

小技巧在此分享以饕众人,顺便大力夸一下男盆友~~你最萌啦么么哒~~


服务支持

我们珍惜您每一次在线询盘,有问必答,用专业的态度,贴心的服务。

让您真正感受到我们的与众不同!

0.038594s