Created
November 19, 2024 13:05
-
-
Save isurfer21/0d6c42b31276b2cb00579ebf9bbc86c8 to your computer and use it in GitHub Desktop.
Revisions
-
isurfer21 revised this gist
Nov 19, 2024 . No changes.There are no files selected for viewing
-
isurfer21 created this gist
Nov 19, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #!/bin/bash # Check if at least two arguments are provided (at least one source and one output) if [ "$#" -lt 2 ]; then echo "Usage: ${0##*/} output.pdf source1.pdf [source2.pdf ... sourceN.pdf]" exit 1 fi # The first argument is the output file output_file="$1" # The remaining arguments are the source PDF files shift # Remove the first argument from the list source_files="$@" # Run Ghostscript to merge the PDFs gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="$output_file" $source_files # Check if the merge was successful if [ $? -eq 0 ]; then echo "Merged PDF successfully!" else echo "Error while merging PDFs!" exit 1 fi