Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.