决定像罗胖一样,坚持转发他的60“语音, 看我能不能一样坚持下来!

Mac os 用automator批量将word转成pdf

技术笔记 eagle 32441℃ 0评论

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

尼玛同事总是布置很麻烦的事让我做。
比如给我一份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文档都存在了指定的文件夹里!再也不用花宝贵的时间在无聊的事情上面了!

转载请注明:艾依小站 » Mac os 用automator批量将word转成pdf

喜欢 (0)or分享 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址