Skip to content

Instantly share code, notes, and snippets.

@khufkens
Last active December 23, 2019 13:38
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save khufkens/5fe99a9606f544b2d5d6a356a3f93fdd to your computer and use it in GitHub Desktop.
Correct PDF author / title meta-data
#!/bin/bash
# Insert PDF meta-data into exif header
# for pdf files with format author - year - title.pdf.
# This allows e-readers to query meta-data for proper
# display and sorting of authors and titles
# (note: relies on exiftool)
for filename in *.pdf; do
noext=`echo "${filename%.*}"`
IFS='-' read -ra NAMES <<< "$noext"
author=`echo ${NAMES[0]} ${NAMES[1]}`
title=`echo ${NAMES[@]:2:99}`
echo "Processing: $filename"
exiftool -Author="$author" -Title="$title" -CreateDate="$year" "$filename"
done
# cleanup
rm *.pdf_original
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment