#!/bin/bash
# Loop through all PDF files in the current directory
for file in *.pdf; do
  # Skip if no PDF files
  [ -e "$file" ] || continue
  # Set output file name
  output="${file%.pdf}.bw.pdf"
  echo "Converting: $file -> $output"
  # Ghostscript command to convert to grayscale
  gs \
    -sDEVICE=pdfwrite \
    -dCompatibilityLevel=1.4 \
    -dProcessColorModel=/DeviceGray \
    -dColorConversionStrategy=/Gray \
    -dColorConversionStrategyForImages=/Gray \
    -dAutoRotatePages=/None \
    -dNOPAUSE -dBATCH -dQUIET \
    -sOutputFile="$output" "$file"
done
Friday, July 18, 2025
bash ghostscript conversion of color pdfs to b&w
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment