I have a creative commons license in one .pdf
file, say license.pdf
. I want to merge this license.pdf
as a first page in another .pdf
file. I can do it manually by the following command:
pdftk license.pdf t2.pdf output t2merged.pdf
But, I am having more than 4000 .pdf
files in a folder and want to add the license.pdf
to all of the 4000 .pdf
s as a first page. How can I automate this process?
I tried. the following outputs came in the terminal.
info-farmer-lm17mate@64bit-Lenovo-Flex-2-14 ~/Desktop/LICENSEs $ sudo chmod u+x add-license.sh [sudo] password for info-farmer-lm17mate: info-farmer-lm17mate@64bit-Lenovo-Flex-2-14 ~/Desktop/LICENSEs $ ./add-license.sh Error: Unable to find file. Error: Failed to open PDF file: edits/files/2mergedpdffile.pdf Done. Input errors, so no output created. Error: Unable to find file. Error: Failed to open PDF file: edits/files/A_Vocabulary_of_English_and_Tamil_Words-google.pdf Done. Input errors, so no output created.
@0x450 still facing the same error as above
Let's assume that all of your "4000"
.pdf
files are located in a single directory (for examplefiles
) and thelicense.pdf
is directly outside this folder. Then you could easily iterate through each file and concatenate it with your license. This script should do the trick:At the end all modified files will be contained in the folder
edits
, which is at the same level asfiles
.Make the script executable with
chmod u+x name-of-the-script
and run it with./name-of-the-script
and don't forget to place it in the same directory where thelicense.pdf
file is stored.