Skip to content

Instantly share code, notes, and snippets.

@xoofx
Created January 2, 2015 08:46
Show Gist options
  • Save xoofx/61cb6850dc9c4bdcb81c to your computer and use it in GitHub Desktop.
Save xoofx/61cb6850dc9c4bdcb81c to your computer and use it in GitHub Desktop.
Shrink all pdf files in a folder (Windows)
@echo off
REM Install Ghostscript 64bit from http://www.ghostscript.com/download/gsdnld.html
REM Shrink all pdfs files in the current directory where this script is run and output to the
REM compressed sub-folder
setlocal
set GS_BIN=C:\Program Files\gs\gs9.15\bin\gswin64c.exe
set GS_OUTPUT_DIR=compressed
mkdir %GS_OUTPUT_DIR%
for %%i in (*.pdf) do "%GS_BIN%" -dNOPAUSE -dBATCH -dSAFER -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -sDEVICE=pdfwrite -sOutputFile="%GS_OUTPUT_DIR%\%%i" "%%i"
@jb0hn
Copy link

jb0hn commented Apr 2, 2020

Please update line 6 to the current version of Ghostscript gs9.52 (as at April 2, 2020).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment