diff options
Diffstat (limited to 'transcribeall')
| -rwxr-xr-x | transcribeall | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/transcribeall b/transcribeall new file mode 100755 index 0000000..a2de999 --- /dev/null +++ b/transcribeall @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +usage="$0 -o <output_dir> <file>..." + +# Parse flags +outdir="" +while getopts "o:" opt; do + case "$opt" in + o) + outdir="${OPTARG%/}";; + *) + echo Usage: $usage >&2 + exit 1;; + esac +done +shift $((OPTIND - 1)) +if [ -z "$outdir" ]; then + echo Usage: $usage >&2 + exit 1 +fi + +# Transcribe each file +while [ $# -gt 0 ]; do + in="$1" + base="${1%.*}" + out="${outdir}/${base}.srt" + wip="${outdir}/.${base}.srt.wip" # work-in-progress + shift + + # Check work-in-progress from previous run + if [ -e "$wip" ]; then + echo "Warning: '$out' in-progress; overwriting." >&2 + rm -f "$out" "$wip" # remove partial output and restart from scratch + fi + + # Transcribe if not done already + if [ ! -e "$out" ]; then + touch "$wip" + echo "'$in' -> '$out'" >&2 + transcribe "$in" >"$out" + rm "$wip" + else + echo "'$out' already exists; skipping." >&2 + fi +done +echo done >&2 |