Tuesday, December 7, 2010

Merge PDFs using Ghost Script (CutePDF)

Dear Blog,

Here is a batch file (.cmd or .bat) to merge PDFs

@echo off
echo -------------------------------------------------------------------------
echo  This will merge all your pdfs in the current directory to an output.pdf
echo -------------------------------------------------------------------------
echo.
Setlocal EnableDelayedExpansion
%~d0
cd %~p0
set /p MERGEFILE=Output file (no need to add .pdf)? 
set PDFMERGE=
for %%f in (*.pdf) do set PDFMERGE=!PDFMERGE! "%%f"
"C:\Program Files\GPLGS\gswin32c" -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -sOutputFile="%MERGEFILE%.pdf" %PDFMERGE%
pause

No comments:

Post a Comment