From 5fafa809e08b833b9144fde08f107c251b159881 Mon Sep 17 00:00:00 2001 From: Leo Butler Date: Sun, 28 Jun 2020 17:32:15 -0500 Subject: [PATCH] clean up transcoded files TODO: use the db to find these files --- myth-clean-recordings.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 myth-clean-recordings.sh diff --git a/myth-clean-recordings.sh b/myth-clean-recordings.sh new file mode 100755 index 0000000..feeaff8 --- /dev/null +++ b/myth-clean-recordings.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -aex +recordingsdir=${recordingsdir:-"/var/lib/mythtv/recordings/"} +rm=${rm:-"/bin/rm -f"} +cutoff=$(date --date='-2 weeks' +%s) +echo cutoff is $cutoff + +cd "$recordingsdir" +cleanables=$(for f in *mkv; do ls ${f/.mkv/}.{ts,mpg,ts.png,mpg.png} 2>/dev/null; done | sed 's/\n/ /g;') + +d=0 +for f in ${cleanables}; do + Z=$(stat --format="%Z" $f) + if test $Z -lt $cutoff; then + $rm $f + d=$((d+1)) + fi +done + +echo Deleted $d files. Done.