Created
January 25, 2018 22:06
-
-
Save raberto-nowhere/071b7753694c68eb3397d0db665effa1 to your computer and use it in GitHub Desktop.
Extract torrents from rtorrent sessions
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
#!/bin/bash | |
[ $# -lt 3 ] && { | |
echo 'Need arguments. look at script..' | |
exit 1 | |
} | |
mode="$1" | |
tracker="$2" | |
outputdir="$3" | |
sessiondir="/home/<>/.session" | |
count=0 | |
[ ! -d "${outputdir}" ] && mkdir "${outputdir}" | |
if [ "${mode}" = "cp" ] || [ "${mode}" = "copy" ]; then | |
mode="cp" | |
elif [ "${mode}" = "mv" ] || [ "${mode}" = "move" ]; then | |
mode="mv" | |
fi | |
for torrent in $(grep "${tracker}" "${sessiondir}"/* -l | awk -F/ '{print $NF}' | cut -d. -f1 | sort | uniq); do | |
"${mode}" "${sessiondir}/${torrent}"* "${outputdir}"/ | |
count=$((count+1)) | |
done | |
echo "Copied ${count} torrents" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment