altered the script to list all formats in PmWiki page-text variable form
authorJonathan Blake <jonathan.blake@projectaon.org>
Sun, 28 Oct 2012 01:16:34 +0000 (01:16 +0000)
committerJonathan Blake <jonathan.blake@projectaon.org>
Sun, 28 Oct 2012 01:16:34 +0000 (01:16 +0000)
git-svn-id: https://projectaon.org/data/trunk@2152 f6f3e2d7-ff33-0410-aaf5-b4bee2cdac11

common/scripts/list-file-sizes.sh

index 1b92073..b1989d2 100755 (executable)
@@ -1,10 +1,53 @@
 #!/bin/sh
-# List the file sizes of a book, should be executed in a parent directory of
-#   all the files to be found
+# list book file sizes in page-text directive form, should be executed in a
+#   parent directory of all the files to be found
 # Usage: list-file-sizes.sh bookcode
 
-du -h `find . -path "*xhtml-less-simple*$1"`
-find . -name "$1.*" \
-    | grep -v "\.svn\|\.xml\|\.dot\|\.log" \
-    | xargs ls -lh \
-    | awk '{print $5 "\t" $9}'
+list_file_size () {
+    size=''
+    if [ -f "$2" ]; then
+        size=`ls -lh $2 \
+            | awk '{print $5}' \
+            | sed -e 's/\([MK]\)$/ {\1iB}/'`
+    fi
+    echo "(:$1:$size:)"
+
+    return 0
+}
+
+list_dir_size () {
+    size=''
+    if [ -d "$2" ]; then
+        size=`du -h $2 \
+            | awk '{print $1}' \
+            | sed -e 's/\([MK]\)$/ {\1iB}/'`
+    fi
+    echo "(:$1:$size:)"
+
+    return 0
+}
+
+####
+
+list_file_size xhtml-zip-size \
+    `find . -path "*xhtml/*$1.zip"`
+list_dir_size xhtml-less-simple-size \
+    `find . -path "*xhtml-less-simple*$1"`
+list_file_size xhtml-less-simple-zip-size \
+    `find . -path "*xhtml-less-simple/*$1.zip"`
+list_file_size xhtml-simple-size \
+    `find . -path "*xhtml-simple/*$1.htm"`
+list_file_size xhtml-simple-zip-size \
+    `find . -path "*xhtml-simple/*$1.zip"`
+list_file_size pdf-size \
+    `find . -name "$1.pdf"`
+list_file_size epub-size \
+    `find . -name "$1.epub"`
+list_file_size mobi-size \
+    `find . -name "$1.mobi"`
+list_file_size fb2-size \
+    `find . -name "$1.fb2"`
+list_file_size pdb-size \
+    `find . -name "$1.pdb"`
+list_file_size lrf-size \
+    `find . -name "$1.lrf"`