Skip to content

Instantly share code, notes, and snippets.

@noah
Created June 3, 2010 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noah/423529 to your computer and use it in GitHub Desktop.
Save noah/423529 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
SESSION_DIR = '/path/to/.sessions'
# ^ should match session_path from .rtorrent.rc
MV_DIR = '/downloads/complete/tracker1.com'
# ^ Change this to path these files should have been moved to
import os
import sys
import glob
try:
from bencode import bdecode,bencode
except:
print "Please rune # easy_install BitTorrent_bencode"
sys.exit()
sys.path.append('/usr/lib/python2.6/site-packages/BTL')
for torrent in glob.glob(SESSION_DIR):
data = bdecode(open(str(torrent),'rb').read())
path = data['rtorrent']['directory']
dir = os.path.basename(path)
target = os.path.join(MV_DIR,dir)
os.system("mv '%s' '%s'" % (path,target))
data['rtorrent']['directory'] = target
data = bencode(data)
f = open(str(torrent),'w')
f.write(data)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment