The first version adds '-compressed' to the newly created PDF file.
I wanted to make the same code but overwrite the original.
I've tried using Google Gemini and Chat GPT, the code they give seems to be OK when I read through... but doesn't work.
One thing... the code should pause at the end... for some reason it doesn't pause. How can I change to make it pause? I don't understand why it doesn't pause.
When the new code doesn't work, there must be errors thrown - but I can't read these because the DOS window doesn't pause.
Here is the original code I have:
Code: Select all
@ECHO OFF
REM Loop through each PDF file passed as arguments
:loop
IF "%~1"=="" GOTO :eof
REM Compose the output filename
SET "outputFile=%~n1-compressed.pdf"
REM Process the PDF and output to the unique filename
"C:\Program Files\gs\gs10.03.0\bin\gswin64c.exe" -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dSAFER -sOutputFile="%outputFile%" "%~1"
SHIFT
GOTO :loop
ECHO Finished processing PDFs.
TIMEOUT /T 20
Thanks.