You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
# prune_dir - prune directory by deleting files if we are low on space
#
DIR=$1
CAPACITY_LIMIT=$2
if [ "$DIR" == "" ]; then
echo "ERROR: directory not specified"
exit 1
fi
if ! cd $DIR; then
echo "ERROR: unable to chdir to directory '$DIR'"
exit 2
fi
if [ "$CAPACITY_LIMIT" == "" ]; then
CAPACITY_LIMIT=95 # default limit
fi
CAPACITY=$(df -k . | awk '{gsub("%",""); capacity=$5}; END {print capacity}')
if [ $CAPACITY -gt $CAPACITY_LIMIT ]; then
# Get list of files, oldest first.
# Delete the oldest files until we are below the limit.
# Just delete regular files, ignore directories.
find $DIR -type f -iregex ".*.\(mp4\|jpg\|png\|log\|json\|m4a\|aac\|flac\|mp3\|ogg\|opus\|wav\|mka\|mkv\|mpg\|ogv\|ts\|wma\|wmv\|webm\|part\|ytdl\|ffmpeg\.txt\)$" -print0 | xargs -0 ls -tr | while read FILE; do
if rm -f "$FILE"; then
echo "Deleted $FILE"
CAPACITY=$(df -k . | awk '{gsub("%",""); capacity=$5}; END {print capacity}')