cd /news/developer-tools/strip-pdf-metadata · home topics developer-tools article
[ARTICLE · art-10818] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Strip PDF Metadata

The article describes a shell script (`clean_pdf.sh`) that recursively finds PDF files in a specified directory (or the current directory) and strips their top-level metadata using `exiftool` and `qpdf`. The script creates a temporary clean copy of each PDF, linearizes it, and replaces the original file, though it notes that only file-level metadata is removed, not metadata within embedded images. The code is provided as-is with no guarantees of safety or effectiveness.

read1 min views22 publishedJan 26, 2022

clean_pdf.sh

  This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.

Learn more about bidirectional Unicode characters

Show hidden characters

#

#

#

#

#

GREEN="\e[32m"

RED="\e[31m"

CLEAR="\e[0m"



DIR="${1:-.}"

echo "Cleaning PDFs in directory $DIR"

find $DIR -type f -name "*.pdf" | while read -r i do

  TMP=${i%.*}_clean.pdf


  if [ -f "$TMP" ]; then

      rm "$TMP";

fi

  exiftool -q -q -all:all= "$i" -o "$TMP"

  qpdf --linearize --deterministic-id --replace-input "$TMP"

  echo -e $(printf "${GREEN}Processed ${RED}${i} ${CLEAR}as ${GREEN}${TMP}${CLEAR}")

done

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/strip-pdf-metadata] indexed:0 read:1min 2022-01-26 ·