Ghostscript − Concatenate pages with different orientations

Published on

Concatenate multiple PDF documents while preserving orientation (portrait/landscape) of each page:

$ gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dAutoRotatePages=/PageByPage -sOutputFile=concatenated.pdf $(ls -v doc*.pdf)