Mac OS X: How to merge pdf files in a directory according to their file names I want to merge several hundred pdf files in a directory automatically according to their file names.

E.g.

The files 
1000.1.pdf
1000.2.pdf
1000.3.pdf
1000.x.pdf should be merged into 1000.pdf

and

2000.abc.pdf
2000.def.pdf
2000.ghi.pdf
2000.jkl.pdf
2000.5.pdf into 2000.pdf.

I don’t want to use solutions based on Preview/Automator (if available) because compared to third party software like Adobe Acrobat or PDFpen merging pdf files often (depending on the source documents) results in a significant increase in file size (see e.g. What causes PDF file size to increase when saving in Preview?) 

Do you have any recommendations? Thank you!
There’s a Python script hidden in Automator.app that joins .PDF-files

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py --help
Usage: join [--output &lt;file&gt;] [--shuffle] [--verbose]


Example usage:

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py --output all.pdf *.pdf