I have updated the macro again, because I noticed the files were not merged alphabetically.
This has now been solved.
Keyboard Maestro 8.2.1 “Merge selected pdfs to new pdf-v4” Macro
I have updated the macro again, because I noticed the files were not merged alphabetically.
This has now been solved.
Keyboard Maestro 8.2.1 “Merge selected pdfs to new pdf-v4” Macro
Hey Jimmy,
That's odd. The Finder-Selection action should return items sorted the same as shown in the Finder with name-sort.
Can you provide a sample of items that were NOT merged alphabetically?
The actual sort and the desired sort?
Also – note that the way you're using sort
will separate uppercase from lowercase.
Unless you want this to be so, you need this switch:
--ignore-case
Also – note that sort
may NOT handle UTF8 properly.
-Chris
Hey Jimmy,
I ran some tests, and Apple has changed how AppleScript acquires selected items. It now honors the Finder-sort -- it used to return items alpha-sorted no matter what the Finder-sort was.
So the sample I requested is now moot.
-Chris
In my test I got last created first in the merged file. Then second last created and so on.
Maybe it honours how I selected the files?
I selected the last and hold down shift and selected the first.
That's possible.
Which version of macOS are you using? I'm on macOS 10.12.6.
-Chris
I am using High Sierra 10.13.4
Thanks for this great macro!
However, I’m running into the following issue:
2018-11-15 10:41:19 pdftk /Users/dms/ZEVRIX/test/fiche-technique-DucoBox-Eco-p1.pdf /Users/dms/ZEVRIX/test/fiche-technique-DucoBox-Eco-p2.pdf /Users/dms/ZEVRIX/test/fiche-technique-DucoBox-Eco-p3.pdf cat output /Users/dms/ZEVRIX/test/test.pdf
xargs: pdftk: No such file or directory
Macro “Merge selected pdfs to new pdf-v4” cancelled (while executing Execute Shell Script).
The PDF toolkit has been installed. If I manually use pdftk using terminal, I don’t get any ‘no such file or directory’ error.
Any ideas?
Hey @dmduco,
It looks like you have a path problem. Take a look at this, and see if it helps you solve it.
Create a PATH Environment Variable for Keyboard Maestro and Add /usr/local/bin to the Default Path
-Chris
Hey @dmduco,
You can find where pdftk is located by running this in the Terminal:
type pdftk
You'll get a result that looks something like this:
pdftk is /usr/local/bin/pdftk
If you run the Terminal command in an Execute a Shell Script action you can find out if Keyboard Maestro see it.
A bit more info:
Some information on the Unix PATH
-Chris
@ccstone, you're awesome!
I went with the variable method to get the unix path correct, so I don't have to mess around in the original action.
Macro is running great now! (it works much faster than a similar action for automator btw)
Any idea how I can control the order of the files? If possible, I would like them to be in order of date modified. I tried adding a For Each Path in folder but couldn't get it to work.
Thanks
Do you actually have pdftk
installed?
I do not know how to do that. This macro just sorts it alphabetically.
Yes, I do. And the Macro works; I would just prefer to be able to merge the documents in a different order.
How are you getting the files "into" your macro? Both AppleScript's and KM's "selected items" honour the Finder's current sort mode, so you could select your files and sort by "Date Modified" before triggering the macro.
Nice idea. The problem is that the macro -- or maybe pdtkf when called with wildcards -- sorts into alphabetical order and then combines the files. At least, I think that is what is going on.
I did have an Automator workflow that did what I needed, but it seems to be broken with changes to the combine PDFs command.
Possibly I could use A Better Finder Renamer to rename the files adding a prefix in order of modification date. That's one I need to investigate to see how it might work with KM.
Ah -- @JimmyHartington's put in an explicit "Sort" action to make it ASCII order regardless of Finder sort settings:
Disable that and you'll probably (untested) get the files merged in Finder order.
(Yes, shell globbing does result in an ASCII-sorted list, but I can't see that going on here.)
I tried, but got an error I am not yet capable of figuring out. I have reverted to my original plan of renaming with ABFR and then using the original version 1 of this macro.
Two steps, for now, but still better than what I was doing before, so I will take it.
Thanks for all your help. KM is clearly very powerful, and will need more study.
Not a small instruction
I'm locking this topic because it is a spam-magnet. If you have a legitimate need to post here, ask me.