Skip to content

Instantly share code, notes, and snippets.

@DavyLandman
Last active August 29, 2015 14:07
Show Gist options
  • Save DavyLandman/c0dd99cdbee35d1a9a4e to your computer and use it in GitHub Desktop.
Save DavyLandman/c0dd99cdbee35d1a9a4e to your computer and use it in GitHub Desktop.
Rename pdf's based on metadata (requires pdfinfo from the poppler package)
# It uses the pdf meta data to rename the file to the title of the pdf
# on osx it requires poppler installed: brew install poppler
find . -type f -name "*.pdf" -exec sh -c 'mv "$0" "$(pdfinfo $0 | sed -n "/^Title/ s/Title:\(.*\)/\1.pdf/p" | sed "s/^[ \t]*//" | sed -e "s/[^A-Za-z0-9._-]/_/g")"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment