Initial public release of pdf-tools

Command-line tools for marked-up PDFs and scanned handwritten notes:
pdf-scrub, pdf-notes-md, scan-notes-md (Ollama by default, Claude on
request), scan-notes-index (per-page search metadata), and
scan-notes-stats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ZSvbNaLhgFuTm7wmkgbWs
This commit is contained in:
Eric Furst 2026-11-03 07:25:51 -05:00
commit e464871b69
29 changed files with 5296 additions and 0 deletions

56
scripts/batch-scan.sh Executable file
View file

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# batch-scan.sh — transcribe every PDF in a folder with scan-notes-md.
#
# usage: batch-scan.sh <folder> [scan-notes-md options...]
#
# PDFs that already have a <stem>.md are skipped, and an interrupted PDF
# resumes from its last saved page, so the script can simply be rerun. A
# failed PDF is reported and the batch moves on to the next one. Extra
# options are passed to scan-notes-md; the default is --backend ollama, so
# nothing is sent to a cloud service unless you ask for it.
#
# Long runs belong in tmux: tmux new -s scan 'batch-scan.sh ~/notebooks'
set -uo pipefail
if [[ $# -lt 1 || ! -d "$1" ]]; then
echo "usage: $0 <folder> [scan-notes-md options...]" >&2
exit 64
fi
dir="$1"; shift
opts=("$@")
[[ ${#opts[@]} -eq 0 ]] && opts=(--backend ollama)
if command -v scan-notes-md >/dev/null 2>&1; then
run() { scan-notes-md "$@"; }
else
: "${PDF_TOOLS_DIR:?set PDF_TOOLS_DIR or install scan-notes-md}"
run() { (cd "$PDF_TOOLS_DIR" && uv run --quiet scan-notes-md "$@"); }
fi
pdfs=()
while IFS= read -r -d '' f; do pdfs+=("$f"); done \
< <(find "$dir" -type f -iname '*.pdf' -not -name '.*' -print0 | sort -z)
total=${#pdfs[@]}
done_n=0; skipped=0; failed=()
start=$(date +%s)
for i in "${!pdfs[@]}"; do
pdf="${pdfs[$i]}"
md="${pdf%.*}.md"
echo "=== [$((i + 1))/$total] ${pdf#"$dir"/} ($(date '+%H:%M'))" >&2
if [[ -e "$md" ]]; then
echo "already transcribed; skipping" >&2
skipped=$((skipped + 1))
continue
fi
if run "${opts[@]}" "$pdf"; then
done_n=$((done_n + 1))
else
failed+=("${pdf#"$dir"/}")
fi
done
mins=$(( ($(date +%s) - start) / 60 ))
echo "=== finished in ${mins} min: $done_n transcribed, $skipped skipped, ${#failed[@]} failed" >&2
for f in ${failed[@]+"${failed[@]}"}; do echo "failed: $f" >&2; done
[[ ${#failed[@]} -eq 0 ]]