0

Say I have a *.zip file, and want to use the unzipped files - more precisely the filenames - directly as input to another command in the terminal. How could this be accomplished?

An example:
- I have a zip-file containing several pdf-files
- I want to merge the pdf-files to one, using e.g. ghostscript

gs -sDEVICE=pdfwriter -sOutputFile=out.pdf <pdf-files from zip>
some_user
  • 111

1 Answers1

0

Append/concat .pdf files from a zip file:

$ > out.pdf; xargs -a <(zipinfo -1 in.zip) -I {} \
  sh -c 'mv out.pdf tmp.pdf; unzip -p in.zip "$1" | \
  gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -o out.pdf tmp.pdf -' _ {}

Using fuse-zip:

$ mkdir -p zip && fuse-zip -r in.zip zip && \
  gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -o out.pdf zip/* && fusermount -u zip