I wrote a simple bash script as I need to split multiple pdfs into 2 pdfs on a regular basis. I need them to be split in the same sequence each time (pages 1-5 and 6 to last page). I need the newly split pdfs to be named uniquely so I can keep them apart (i.e. inv-1.pdf rec-1.pdf; inv-2.pdf rec-2.pdf, etc). My script only splits the 1 pdf when I have 5+ in the folder. Any suggestions are appreciated.
#!/bin/bash
for file in $(ls REQ*.pdf)
do
qpdf ${file} --pages . 1-5 -- inv-%d.pdf |\
qpdf ${file} --pages . 6-z -- rec-%d.pdf |\
echo >> ${file}
done
'''