Mac Automator - Combine PDF files, save in same folder

余生长醉 提交于 2019-11-30 07:44:29

There is no automator action to get the name of a file's container, nor is there an action to get the path of a file's container, so that you can set those to variables. So, you'll have to use an Applescript action to get each of those. Here is an example of a working automator workflow accomplishing what you have asked, assuming you place it in your service that accepts PDFs.

Thanks to jweaks for his script. Super helpful and elegant.

I found and fixed a small bug:

I got his workflow to put the file into the same folder as the original PDFs rather than on the desktop by tweaking the Applescripts to talk to the Finder (instead of System Events) and return an alias, which seems to be what Move Finder Items is expecting:

So…

  1. Service receives PDF files in Finder
  2. Set Value of Variable : originalPDFs
  3. Run Applescript:

Revised Applescript:

on run {input}
    tell application "Finder" to return (container of item 1 of input) as alias
end run
  1. Set Value of Variable : containerAlias
  2. Run Applescript:

Revised Applescript 2

on run {input, parameters}
    -- the input is the enclosing folder which was output from the previous Applescript
    tell application "Finder" to return name of (item 1 of input) 
end run
  1. Set Value of Variable : containerName

  2. Get Value of Variable : originalPDFs ; select Options > "ignore this action’s input"

  3. Combine PDF Pages
  4. Rename Finder Items: Name Single Item, Basename only, containerName "(combined)”
  5. Move Finder Items : container Alias

Hope this helps… I’m sure I’ll look up this answer again in a few years :)

Here’s a screenshot:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!