Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AnonymerNiklasistanonym/4cf87f2101d01fe87b459f010b07d280 to your computer and use it in GitHub Desktop.
Save AnonymerNiklasistanonym/4cf87f2101d01fe87b459f010b07d280 to your computer and use it in GitHub Desktop.
Convert a multi page PDF file to many single page PDF files (and optionally run a command for every PDF file that will be created)
#!/usr/bin/env bash
# Description:
# Seperate a PDF document into many single page PDF documents
# Arguments:
# 1) The path of the PDF file
# 2) The output directory
# 3) The output file name NAME_%d.pdf
# Get page number
PAGE_NUMBER=$(pdfinfo "$1" | grep Pages | awk '{print $2}')
# Create single page PDF files out of the multipage PDF file
pdfseparate "$1" "$2/$3_%d.pdf"
# Optional, do something for every page
for (( c=1; c<=$PAGE_NUMBER; c++ ))
do
#inkscape "$2/$3_$c.pdf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment