ffmpeg-mythtv/myth-clean-recordings.sh
Leo Butler 5fafa809e0 clean up transcoded files
TODO: use the db to find these files
2020-07-27 17:33:47 -05:00

21 lines
452 B
Bash
Executable File

#!/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.