summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-06-25 16:52:39 +0100
committerNick White <git@njw.name>2019-06-25 16:52:39 +0100
commit85129e39d214f13ce3974133bc17ed1eacae1d02 (patch)
tree6ee0471b8fed7d4c5d99b4f93fd1d4e557a1947c
parent0ea7b7f8c536d3b99831b689c846d8a1b64440ec (diff)
Add fixoverwiped.sh script
-rw-r--r--fixoverwiped.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/fixoverwiped.sh b/fixoverwiped.sh
new file mode 100644
index 0000000..199b4a0
--- /dev/null
+++ b/fixoverwiped.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+usage="Usage: $0 overwipedfile origdir nowipedir newdir"
+test $# -ne 4 && echo "$usage" && exit 1
+
+overwiped="$1"
+origdir="$2"
+nowipedir="$3"
+newdir="$4"
+
+if ! test -f "$1"; then
+ echo "Error: no overwiped file found"
+ exit 1
+fi
+
+for i in "$origdir" "$nowipedir"; do
+ if ! test -d "$i"; then
+ echo "Error: no directory "$i" found"
+ exit 1
+ fi
+done
+
+if test -d "$newdir"; then
+ echo "Error: directory $newdir exists"
+ exit 1
+fi
+
+cp -r "$origdir" "$newdir"
+
+while read i; do
+ pgnum=`echo "$i" | awk '{print $1}'`
+ badone=`echo "$i" | awk '{print $8}' | sed 's/[()]//g'`
+ goodone=`find "${nowipedir}/best" -type f -name "${pgnum}*hocr"|head -n 1|sed 's/.*_bin/bin/;s/.hocr$//'`
+
+ rm "$newdir/${pgnum}_${goodone}.png"
+ cp "$nowipedir/${pgnum}_${goodone}.png" "$newdir"
+
+ rm "$newdir/best/${pgnum}_${badone}.hocr"
+ cp "$nowipedir/${pgnum}_${goodone}.hocr" "$newdir/best"
+done < "$overwiped"
+
+echo "All done. Hopefully $newdir/best should be great now"