OL Learn

Merge PDFs in order in workflow

I have a ton of PDFs named like:

1-sample.pdf
2-sample.pdf
3-sample.pdf

400-sample.pdf
401-sample.pdf
etc.

I want these to be merged in the order of 1,2,3,4,5,6,7,8,9,10,11,12,13,14 etc…

How can I do this in the workflow?

You could use a Folder Listing input task that sorts the files by name. You could then use an XML splitter to split on the <filename> element and concatenate each file into the destination PDF.

However, for this to work as expected, you’ll have to make sure your PDFs are numbered properly. They must all have the same number of digits (e.g. 0001, 0002…0020, 0021 … 0200, 0201… etc.) because the Folder Listing task sorts the names in alphabetical order, rather than in numerical order. For instance, in alphabetical order, 1-sample, 10-sample and 100-sample all come before 2-sample, but if all names have the same number of digits, then the alphabetical and numerical orders will be the same.

that’s what I was hoping wouldn’t be the case. Would be great to have it sort in numerical order. This is a good workaround though, thank you