metadata scripts
This commit is contained in:
1 parent
2044545136
commit
83e6d7ee22
3 files changed
+382
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASE="${1:-.}"
|
||||
|
||||
for dir in "$BASE"/*/; do
|
||||
[ -d "$dir" ] || continue
|
||||
|
||||
title=$(basename "$dir")
|
||||
|
||||
# Skip directories starting with a number
|
||||
[[ "$title" =~ ^[0-9] ]] && continue
|
||||
|
||||
# Author = parent directory of book directory
|
||||
author=$(basename "$(dirname "$dir")")
|
||||
|
||||
# Fix author name formatting
|
||||
author="${author//JRR/J. R. R.}"
|
||||
|
||||
for pdf in "$dir"/*.pdf; do
|
||||
[ -f "$pdf" ] || continue
|
||||
|
||||
opf="$dir/metadata.opf"
|
||||
|
||||
cat > "$opf" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:opf="http://www.idpf.org/2007/opf"
|
||||
version="2.0">
|
||||
<metadata>
|
||||
<dc:title>$title</dc:title>
|
||||
<dc:creator opf:role="aut">$author</dc:creator>
|
||||
<dc:language>en</dc:language>
|
||||
<dc:format>application/pdf</dc:format>
|
||||
</metadata>
|
||||
</package>
|
||||
EOF
|
||||
|
||||
echo "Created: $opf"
|
||||
done
|
||||
done
|
||||
Reference in new issue
Block a user