mirror of
https://github.com/sebaschi/dotfiles.git
synced 2025-11-09 11:24:27 +01:00
38 lines
783 B
Bash
Executable File
38 lines
783 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Check if qpdf is installed
|
|
if ! command -v qpdf &> /dev/null; then
|
|
echo "Error: qpdf could not be found. Please install qpdf."
|
|
exit 1
|
|
fi
|
|
|
|
# Target PDF filename
|
|
output_pdf="$1.pdf"
|
|
if [[ -z "$1" ]]; then
|
|
echo "Usage: $0 <output-file-base-name>"
|
|
exit 1
|
|
fi
|
|
|
|
# Prepare an array to hold the PDF files
|
|
pdf_files=()
|
|
shopt -s nullglob
|
|
for file in *.pdf; do
|
|
pdf_files+=("$file")
|
|
done
|
|
|
|
# Check if we found any PDF files
|
|
if [[ ${#pdf_files[@]} -eq 0 ]]; then
|
|
echo "No PDF files found in the current directory."
|
|
exit 1
|
|
fi
|
|
|
|
# Sort files just in case
|
|
IFS=$'\n' pdf_files=($(sort <<<"${pdf_files[*]}"))
|
|
unset IFS
|
|
|
|
# Run qpdf to combine PDF files
|
|
qpdf --empty --pages "${pdf_files[@]}" -- "$output_pdf"
|
|
|
|
echo "PDF files combined into $output_pdf"
|
|
|