Merge two PDF files automatically with the input file name as the output file name

0

0

I need to merge several PDF files. What I have is two files, with almost the same name. The name is a code for a product, that consists of the pdf files. One is called 4226469601D.pdf and one is called 4226469601L.pdf. I'm going to have several of these products, and want to create a "automatic batch file" that can merge these files.

The issue is, I need the new file to be called 4226469601.pdf. So it has to take the first 10 numbers in the two files, as the output file. So when I take the next product called 5632987852D.pdf and 5632987852L.pdf the output has to be 5632987852.pdf.

Is this possible?

Troels Løfqvist

Posted 2015-04-09T18:20:35.853

Reputation: 1

Do you need a solution that works on Windows or on another OS? – mguassa – 2015-07-24T20:22:18.637

Answers

1

You can use pdftk tool to do it

#!/bin/bash

#Use the basename as the filename
filename=211

#Merge Using pdftk
pdftk ${filename}D.pdf ${filename}L.pdf cat output ${filename}.pdf

discipulus

Posted 2015-04-09T18:20:35.853

Reputation: 111