Created
March 1, 2011 19:29
-
-
Save seikichi/849716 to your computer and use it in GitHub Desktop.
自炊したpdfから最初と最後の3ページの画像を確認してバーコードを探しファイル名を"<ISBN13>.pdf" に変換.
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 | |
rm -f .image* | |
CHECK=3 | |
for file in *.pdf; do | |
pages=$(pdfinfo "$file" | grep -E '^Pages' | sed -e 's/^Pages:\s*//') && | |
pdfimages -j -l $CHECK "$file" .image_h && | |
pdfimages -j -f $(expr $pages - $CHECK) "$file" .image_t && | |
title="$(zbarimg -q .image* | uniq | grep -E '^EAN-13:978' | sed -e 's/^EAN-13://').pdf" && | |
[ $title != ".pdf" ] && | |
mv "$file" $title || | |
echo "Error in $file" | |
rm -f .image* | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment