A Bash utility to optimize, monochrome-ify, and strip content from PDFs in bulk.
- Compression: Choose from presets (
screen
,ebook
,printer
,prepress
, ordefault
) - Monochrome Conversion: Transform color PDFs to B/W
- Selective Stripping: Drop images, text, and vectors as needed
# Clone repo
git clone https://github.com/tezzytezzy/pdf-batch-processor.git
cd pdf-batch-processor/
# Make executable
chmod +x pdf-batch-processor.sh
./pdf-batch-processor.sh
- Processes every
.pdf
in the current directory - Outputs into
compressed_files/
- Generates
compression_report.log
hp@HP:~$ ./pdf_batch_compressor.sh -h
Usage: pdf_batch_compressor.sh [OPTIONS]
Compresses all .pdf files in the script’s directory into
a fresh ./compressed_files/ folder and emits a log.
Options:
-p, --preset PRE PDFSETTINGS preset. One of:
screen, ebook, printer, prepress, default
-c, --color COL Color strategy: Gray or LeaveColorUnchanged
--gray Shortcut for --color=Gray
-i, --filter-image Add -dFILTERIMAGE
-t, --filter-text Add -dFILTERTEXT
-v, --filter-vector Add -dFILTERVECTOR
-h, --help Show this help and exit
Examples:
# screen preset + gray + image filter
./pdf_batch_compressor.sh --preset=screen --gray --filter-image
# ebook preset, keep colors, text+vector filters
./pdf_batch_compressor.sh -p ebook -i -v
# default preset + LeaveColorUnchanged
./pdf_batch_compressor.sh
# "--gray" takes precedent over "-c LeaveColorUnchanged" where both are supplied
(The following three are equivalent)
./pdf_batch_compressor.sh -c LeaveColorUnchanged --gray
./pdf_batch_compressor.sh -c Gray
./pdf_batch_compressor.sh --gray
Compression Report – Sun Jun 29 10:40:50 AM PDT 2025
Filename Original(bytes) Compressed(bytes) Ratio(%)
MyFile.pdf 167997 24773 14.75
hp@HP:~$ bash --version
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
hp@HP:~$ gs --version
10.02.1
PDF File | File Size | Ratio (%) |
---|---|---|
Original* | 218.4 kB | -- |
Screen preset only | 30.2 kB | 13.82 |
Screen preset and gray | 24.8 kB | 11.36 |
*This is a one-page PDF containing four equally-sized, full-color portrait images and no text.