From 85129e39d214f13ce3974133bc17ed1eacae1d02 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 25 Jun 2019 16:52:39 +0100 Subject: Add fixoverwiped.sh script --- fixoverwiped.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 fixoverwiped.sh 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" -- cgit v1.2.1-24-ge1ad