Created
November 10, 2017 05:24
-
-
Save GrahamWalters/33545334b7d38ce492aa20fbb4d58353 to your computer and use it in GitHub Desktop.
Packt.epub rename
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 | |
get_title () { | |
attr='title' | |
fileloc=`unzip -l "$1" | ggrep -Po '\b[^\s-]*\.opf\b'` | |
metafound=`zipgrep '<dc:'$attr'(.+)>(.+)</dc:'$attr'>' "$1" $fileloc` | |
echo `expr "$metafound" : '.*<dc:'$attr'.*>\(.*\)</dc:'$attr'>.*'` | |
} | |
for file in $(find . -type f -depth 1 -name "*.epub"); do | |
filename=$(get_title "$file") | |
mv "$file" "Packt - $filename.epub" | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment