Combine PDFs to new PDF with filenames as bookmarks
2
votes
0
answers
319
views
I have a directory *foo* containing .pdf files named with pattern *X01, X02, ...*, each two pages long. I want to combine them to a new .pdf, named "_all_YY-MM-DDTHHMMSS.pdf_" that will contain the file names as bookmarks.
I used these two commands. While the first one works well,
$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=all_$(date +"%FT%H%M%S").pdf X*.pdf
the second one, based on [this answer](https://unix.stackexchange.com/a/72457/372935) fails.
$ pdftk all_2023-07-12T094706.pdf update_info {ls | grep X*} output out.pdf
grep: X}: No such file or directory
grep: output: No such file or directory
grep: out.pdf: No such file or directory
Done. Input errors, so no output created.
I was trying to
grep
the ls
for the filenames starting with _X*_, in order to exclude the new combined .pdf names _all..._.
How do I get this to work, preferably by adding update_info
to the first command?
I'm aware of solutions like [this](https://unix.stackexchange.com/a/709643/372935) , but they look rather tedious.
Asked by jay.sf
(237 rep)
Jul 12, 2023, 08:13 AM