blob: a2de999eb47614c82e0cbf0ce2ee3a9f5f5bc8c6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
|