mirror of
https://github.com/tomru/docscan.git
synced 2026-03-03 06:27:21 +01:00
inital commit
This commit is contained in:
46
run.sh
Executable file
46
run.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
shopt -s globstar nullglob
|
||||||
|
|
||||||
|
OCRMYPDF_CMD='docker run --rm -i ocrmypdf'
|
||||||
|
|
||||||
|
SRC_DIR=./test
|
||||||
|
DST_DIR=./dst
|
||||||
|
|
||||||
|
FAILED_DIR=$DST_DIR/failed
|
||||||
|
LOG_DIR=$DST_DIR/logs
|
||||||
|
ARCHIVE_DIR=$DST_DIR/archive
|
||||||
|
|
||||||
|
mkdir -p "$DST_DIR"
|
||||||
|
mkdir -p "$ARCHIVE_DIR"
|
||||||
|
|
||||||
|
function ocrFile() {
|
||||||
|
SRC=$1
|
||||||
|
DST_DIR=$2
|
||||||
|
FILE_NAME=$(basename -- "$SRC")
|
||||||
|
|
||||||
|
DST_PDF=$DST_DIR/${FILE_NAME%.*}.pdf
|
||||||
|
DST_LOG=$LOG_DIR/${FILE_NAME%.*}.log
|
||||||
|
|
||||||
|
$OCRMYPDF_CMD \
|
||||||
|
-l deu \
|
||||||
|
--clean \
|
||||||
|
--rotate-pages \
|
||||||
|
--deskew \
|
||||||
|
- - \
|
||||||
|
< "$FILE" \
|
||||||
|
> "$DST_PDF" 2> "$DST_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
for FILE in "$SRC_DIR"/*.pdf
|
||||||
|
do
|
||||||
|
echo "processing $FILE..."
|
||||||
|
ocrFile "$FILE" "$DST_DIR"
|
||||||
|
# TODO: move to FAILED_DIR and error out
|
||||||
|
echo processed "$FILE"
|
||||||
|
mv "$FILE" "$ARCHIVE_DIR"
|
||||||
|
echo moved "$FILE" to archive
|
||||||
|
done
|
||||||
|
|
||||||
Reference in New Issue
Block a user