Merge PDFs in Numerical Order

Posted by: Karlie

Merge PDFs in Numerical Order - 08/08/18 04:03 PM

Hi there,

What is the best way to merge a large number (up to 4000) of single page PDFs in numerical order based on their name. For example:

Name 1.pdf
Name 2.pdf
Name 3.Pdf
Name 4.pdf

and so.

I tried using the Merge PDF plugin with the alphabetical sorting but this doesn't seem to work. It seems to be a little random.

What's the best way to achieve this?

Thanks in advance, cheers!
Posted by: Yannick Fortin

Re: Merge PDFs in Numerical Order - 08/08/18 04:33 PM

My psychic debugging powers tell me that by "random", you mean "the plugin uses a strict alphabetical order". So "Name 60.pdf" comes after "Name 400.pdf" because the first character that differ is 4 vs 6. Which is obviously not what you want.

One solution would be to pad the numbers with zeroes. This way, "Name 0060.pdf" comes before "Name 0400.pdf", as it should be.

The other solution would be to write a script that implements a sorting algorithm that sorts the way you want and then use the AlambicEdit scripting API to merge the PDF files.
Posted by: Karlie

Re: Merge PDFs in Numerical Order - 08/15/18 04:07 PM

Thank Yannick!

That was exactly it. I have added leading zeros and now it works smile