40 lines
784 B
Bash
Executable File
40 lines
784 B
Bash
Executable File
#! /bin/sh -e
|
|
|
|
. $(dirname $0)/common.sh
|
|
|
|
log "Scanning for DVD title"
|
|
title=$(dvdbackup -I | awk -F \" '/DVD with title/ {print $2}')
|
|
setenv title "$title"
|
|
|
|
# How big is this DVD?
|
|
totalSize=$(dvdbackup -I | awk '/[MK]iB$/ { b += $2 } END { print b }')
|
|
|
|
dvdbackup -p -F -n DVD \
|
|
| tr '\r' '\n' \
|
|
| awk -v total=$totalSize -F '[ /:()]+' '
|
|
function update(bytes) {
|
|
pct = 100 * bytes / total
|
|
if (pct >= nextpct) {
|
|
print pct
|
|
fflush()
|
|
nextpct = pct + 0.5
|
|
}
|
|
}
|
|
|
|
/[MK]iB.$/ {
|
|
read = $(NF-3) * 1024
|
|
if ($(NF-1) == "MiB") {
|
|
read *= 1024
|
|
}
|
|
if (read < last) {
|
|
totalRead += last
|
|
}
|
|
update(totalRead + read)
|
|
last = read
|
|
}
|
|
' \
|
|
| while read val; do
|
|
setenv complete "$val"
|
|
done
|
|
|