diff options
-rw-r--r-- | fixoverwiped.sh | 41 |
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" |