Created
November 2, 2015 19:31
-
-
Save magarcia/ea5467e0724bfc11cac0 to your computer and use it in GitHub Desktop.
Clean finished torrents and remove files if has hard link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function join { local IFS="$1"; shift; echo "$*"; } | |
REMOTE="transmission-remote --auth osmc:osmc" | |
DATA=`$REMOTE --list | grep Finished | awk '{print $1'}` | |
for i in $DATA | |
do | |
FILES=`$REMOTE -t $i -f | grep "^ " | grep -v "#" | awk '{ print substr($0, index($0,$7)) }' | uniq | tr " " "|"` | |
remove=false | |
for f in $FILES | |
do | |
DIR=`echo "/data/Downloads/$f" | tr "|" " "` | |
if [ "$(stat -c %h -- "$DIR")" -gt 1 ]; then | |
remove=true | |
fi | |
done | |
if [ "$remove" == true ]; then | |
$REMOTE -t $i --remove-and-delete | |
echo [`date -u`] Remove `$REMOTE -t $i -i | grep Name | awk '{print $2}'` >> /var/log/torrent-cleaner.log | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment