Last active
December 23, 2019 13:38
-
-
Save khufkens/5fe99a9606f544b2d5d6a356a3f93fdd to your computer and use it in GitHub Desktop.
Correct PDF author / title meta-data
This file contains 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
#!/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