Skip to content

Instantly share code, notes, and snippets.

@Zeta611
Created April 20, 2023 13:53
Show Gist options
  • Save Zeta611/f7ea2b22b53e802ec267c811eb926316 to your computer and use it in GitHub Desktop.
Save Zeta611/f7ea2b22b53e802ec267c811eb926316 to your computer and use it in GitHub Desktop.
[Merge PDFs] #automation
#!/bin/bash
# Check if qpdf is installed
if ! command -v qpdf >/dev/null; then
echo "qpdf not found. Please install qpdf and try again."
exit 1
fi
# Check if enough arguments are supplied
if [ "$#" -lt 3 ]; then
echo "Usage: $0 output.pdf input1.pdf input2.pdf [input3.pdf ...]"
exit 1
fi
# Get output file name
output_file="$1"
shift
# Merge input PDF files
qpdf --empty --pages "$@" -- "$output_file"
echo "Merged PDFs saved as $output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment