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 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, but they look rather tedious.
ls | grep X*
since this gives me exactly the bookmarks I want for each first page of the two-pages and should avoid the interim step of creating an info file first to read in again, and which seems a bit redundant to me. – jay.sf Jul 12 '23 at 08:34ls
output, your shell can already just globX*
(and it's not fragile, unlike thels | grep
construct, which almost certainly doesn't do what you think it does, as well.). Again, the contents info file seems to be the minimum of information any program could need, so you'll have to put that info somewhere. – Marcus Müller Jul 12 '23 at 08:38cat
this in a tempfile and read it in again to give the program the information? – jay.sf Jul 12 '23 at 08:48{ls | grep X*}
makes no sense to me (nor does it to the shell nor yourgrep
, see your error messages), I really don't! I'd refer to the linked answer. – Marcus Müller Jul 12 '23 at 16:00{ls | grep X*}
I'm trying to say, list directory and grep it for filenames starting with X, as a substitute for reading something from a file. – jay.sf Jul 12 '23 at 16:54{ls | grep X*}
, justX*
would be correct. – Marcus Müller Jul 12 '23 at 18:12pdftk all_2023-07-12T094706.pdf update_info X* output out.pdf
, gave meError: expecting "output" keyword. Instead, I got: st_ps_S00002_2023-07-12T202825.pdf
. – jay.sf Jul 12 '23 at 18:53