Show total storage savings in transcode-hevc --status

Parse every Saved: entry in the log to compute cumulative original
size, new size, bytes saved, and percentage reduction so we have a
single command for the transcode impact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ediblerope 2026-04-16 19:56:46 +01:00
parent cb92db7ad8
commit 7d50716bc6

View file

@ -104,13 +104,22 @@ show_status() {
done_count=$(wc -l < "$DONE_LOG") done_count=$(wc -l < "$DONE_LOG")
echo "Completed files: $done_count" echo "Completed files: $done_count"
if [[ -f "$LOG_FILE" ]]; then if [[ -f "$LOG_FILE" ]]; then
local saved echo ""
saved=$(grep "Saved:" "$LOG_FILE" | tail -20) echo "Total savings:"
if [[ -n "$saved" ]]; then awk '
echo "" match($0, /\(([^ ]+) -> ([^)]+)\) Saved:/, a) {
echo "Recent savings:" cmd = "numfmt --from=iec " a[1]; cmd | getline o; close(cmd)
echo "$saved" cmd = "numfmt --from=iec " a[2]; cmd | getline n; close(cmd)
fi orig += o
new += n
}
END {
if (orig == 0) { print " No completed encodes yet."; exit }
saved = orig - new
printf " Original: %.2f GB\n New: %.2f GB\n Saved: %.2f GB (%.1f%%)\n",
orig/1073741824, new/1073741824, saved/1073741824, (saved/orig)*100
}
' "$LOG_FILE"
fi fi
exit 0 exit 0
} }