Created
March 8, 2013 22:11
-
-
Save dyladan/5120324 to your computer and use it in GitHub Desktop.
sorts torrent files into folder by tracker. Just put all your files in a folder called torrents and run this file one level above that folder.
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
require 'bencode' | |
require 'fileutils' | |
Dir.glob('torrents/*.torrent') do |item| | |
if File.directory?(item) | |
next | |
end | |
tracker = BEncode.load_file(item)["announce"].gsub("http://", "").split('/')[0] | |
if tracker == nil | |
next | |
end | |
Dir.mkdir("torrents/"+tracker) unless File.exists?("torrents" + tracker) | |
FileUtils.mv(item, "torrents/" + tracker + "/" + item.split('/')[-1]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment