All pastes #52614 Raw Edit

Stuff

public shellscript v1 · immutable
#52614 ·published 2006-05-01 17:43 UTC
rendered paste body
#!/bin/bash#this script tries to find all the files that are not seeded by rtorrent (in the download dir)#It should deal with all filenames except those containing newlines $'\n' :(#It requires bash 3 and probably GNU/BSD sed#find dirshome_dir=~rtorrent_temp_dir=$(sed -n 's/session[[:space:]]*=[[:space:]]\(.*\)/\1/p' ~/.rtorrent.rc)rtorrent_download_dir=$(sed -n 's/directory[[:space:]]*=[[:space:]]\(.*\)/\1/p' ~/.rtorrent.rc)#avoid the use of eval for ~ expansionrtorrent_temp_dir=${rtorrent_temp_dir//\~/$home_dir}rtorrent_download_dir=${rtorrent_download_dir//\~/$home_dir}#want to use backreferences here but it's awfully slow :(unset seeded_files iwhile read -d $'\0' f do 	strlen="$(strings "$f" | sed -n 's/.*name\([0-9]\+\):.*/\1/p')" #bencoded string lenght	seeded_files[i++]=$(strings "$f" | sed -n 's/.*name'$strlen':\(.\{'$strlen'\}\).*/\1/p')done < <(find $rtorrent_temp_dir -mindepth 1 -maxdepth 1 -type f -iname \*.torrent -print0)echo "theses files are unseeded..."echo -e "size(MB)\tName"while read -d $'\0' filedo	flag=0	for i in $(seq 0 ${#seeded_files[*]})	do		if [[ $(basename "$file") == "${seeded_files[$i]}" ]] ; then			flag=1			break		fi	done	if [[ $flag -eq 0 ]] ; then		du -ms "$file"	fidone < <(find $rtorrent_download_dir -mindepth 1 -maxdepth 1 -print0)