./tools/includer $(SRCDIR)/scantopdf \
| sed "s/@VERSION@/$(VERSION)/" > $(@)
chmod 755 $(@)
+ shellcheck $(@)
$(PACKAGEDIR)/$(BINDIR)/scantopdfgray: \
$(BUILDDIR)/parts/scanbasic.sh
./tools/includer $(SRCDIR)/scantopdfgray \
| sed "s/@VERSION@/$(VERSION)/" > $(@)
chmod 755 $(@)
+ shellcheck $(@)
$(PACKAGEDIR)/$(BINDIR)/scantopdfbw: \
$(BUILDDIR)/parts/scanbasic.sh
./tools/includer $(SRCDIR)/scantopdfgray \
| sed "s/@VERSION@/$(VERSION)/" > $(@)
chmod 755 $(@)
+ shellcheck $(@)
$(PACKAGEDIR)/$(BINDIR)/addocr:
./tools/includer $(SRCDIR)/addocr \
| sed "s/@VERSION@/$(VERSION)/" > $(@)
chmod 755 $(@)
+ shellcheck $(@)
$(PACKAGEDIR)/$(BINDIR)/addkeywords:
./tools/includer $(SRCDIR)/addkeywords \
| sed "s/@VERSION@/$(VERSION)/" > $(@)
chmod 755 $(@)
+ shellcheck $(@)
################################################################################
echo "✅ SUCCESS: addkeywords @VERSION@"
}
-main $*
\ No newline at end of file
+main "$*"
\ No newline at end of file
echo "✅ SUCCESS: addocr @VERSION@"
}
-main $*
\ No newline at end of file
+main "$*"
\ No newline at end of file
|| errlog "missing input" \
|| return $?
- qpdf --linearize $input $output \
+ qpdf --linearize "$input" "$output" \
|| errlog "could not linearize $input" \
|| return $?
- mv $output $input \
+ mv "$output" "$input" \
|| errlog "could not rename $output to $input" \
|| return $?
}
|| return $?
echo "ℹ️ INFO: adding ocr on file $input"
- ocrmypdf --quiet --jobs $jobs --language deu $input $output \
+ ocrmypdf --quiet --jobs "$jobs" --language deu "$input" "$output" \
|| errlog "could not add ocr on $input" \
|| return $?
- [ ! -f $output ] && return 0
+ [ ! -f "$output" ] && return 0
- mv $output $input \
+ mv "$output" "$input" \
|| errlog "could not rename $output to $input" \
|| return $?
- optimize $input \
+ optimize "$input" \
|| return $?
}
get_title_from_file_name()
{
local file_name="$1"
- local title="${file_name%.*}"
+ local title=
+ title="${file_name%.*}"
title="${title#*_}"
title="${title//_/ }"
{
local file_name="$1"
local keywords="$2"
+ local title=
+ local date=
[ -z "$keywords" ] && return 0
- local title=$(get_title_from_file_name "$file_name")
- local date=$(get_date_from_file_name "$file_name")
+ title=$(get_title_from_file_name "$file_name")
+ date=$(get_date_from_file_name "$file_name")
echo "ℹ️ INFO: adding keywords $keywords to $file_name"
exiftool -Title="$title" \
local tiff="$1"
local pdf=${tiff/.tiff/.pdf}
- tiff2pdf $tiff -o $pdf
- rm $tiff
+ tiff2pdf "$tiff" -o "$pdf"
+ rm "$tiff"
}
createonepdf()
| sort \
| parallel convert_tiff_to_pdf {}
- pdftk scanned-$$-*.pdf output $output \
+ pdftk scanned-$$-*.pdf output "$output" \
|| errlog "could not convert into single $output" \
|| return $?
|| errlog "could not remove scanned pdfs" \
|| return $?
- addocr $output \
+ addocr "$output" \
|| return $?
}
|| return $?
local i=
- for i in $(seq $start $end); do
- countno=$(printf "%03d" $i)
- pdfs=$(echo $pdfs "scanned-$$-$countno.pdf")
+ for i in $(seq "$start" "$end"); do
+ countno=$(printf "%03d" "$i")
+ pdfs+=("scanned-$$-$countno.pdf")
done
- pdftk $pdfs output "$basename$(printf "%03d" $start).pdf" \
+ pdftk "${pdfs[@]}" output "$basename$(printf "%03d" "$start").pdf" \
|| errlog "could not create pdf" \
|| return 1
- for pdf in $pdfs; do
+ for pdf in "${pdfs[@]}"; do
rm "$pdf" \
|| errlog "could not delete $pdf" \
|| return 1
|| errlog "missing pdf" \
|| return $?
- trenn=$(pdfgrep "CUTPAGE-CUTPAGE-CUTPAGE-CUTPAGE" $pdf | xargs)
+ trenn=$(pdfgrep "CUTPAGE-CUTPAGE-CUTPAGE-CUTPAGE" "$pdf" | xargs)
[ "$trenn" == "CUTPAGE-CUTPAGE-CUTPAGE-CUTPAGE" ] \
&& echo "true" \
export -f optimize
find . -name "scanned-$$-*.pdf" \
| sort \
- | parallel --keep-order addocr {} $(nproc)
+ | parallel --keep-order addocr {} "$(nproc)"
local startcount=1
local endcount=1
local trenn=
local pdffile=
- for pdffile in scanned-$$-*.pdf; do
- trenn=$(detectsplit $pdffile) \
+ for pdffile in scanned-"$$"-*.pdf; do
+ trenn=$(detectsplit "$pdffile") \
|| return $?
[ "$trenn" != "true" ] \
- || rm $pdffile \
+ || rm "$pdffile" \
|| errlog "could not delete $pdffile" \
|| return $?
[ "$trenn" != "true" ] \
|| return $?
scanimage --source=DocumentFeeder \
- --mode=$mode \
+ --mode="$mode" \
--resolution=300 \
--scanside=Duplex \
--skip-blank-pages=yes \
--format=tiff \
- --batch-count=$pagecount \
+ --batch-count="$pagecount" \
--batch-increment=1 \
--batch=scanned-$$-%03d.tiff \
|| errlog "scan error" \