Skip to content

Instantly share code, notes, and snippets.

@raberto-nowhere
Created January 25, 2018 22:06
Show Gist options
  • Save raberto-nowhere/071b7753694c68eb3397d0db665effa1 to your computer and use it in GitHub Desktop.
Save raberto-nowhere/071b7753694c68eb3397d0db665effa1 to your computer and use it in GitHub Desktop.
Extract torrents from rtorrent sessions
#!/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