Code:
#!/bin/bash
cnt=0
for file in *.pdf
do
mth=$(echo $file|cut -d'_' -f1)
pdftk $file output all/${mth}_${cnt}.pdf owner_pw pass
(( cnt++ ))
done
thanks Chris - using this code but it stops after 4 repetitions/4 files.
Why is it stopping after 4? I get no error output?
Catkin, what im trying to do in English:
I have a directory of PDF files.
The file name convention is:
"January_2342.pdf",
"January_file_3342.pdf",
"January_2442.pdf",
"January_letter_2342.pdf",
"January_file_2342.pdf",
"February_07.pdf",
"Febuary_file_2342.pdf".
The month will always be first.
I want to write a script to encrypt all these files, and keep the month, so my new encrypted files will be:
"january_01.pdf", "january_02.pdf" etc.
The command to encrypt a PDF is:
pdftk original.pdf output encrypted.pdf owner_user password