Created
July 21, 2011 20:44
-
-
Save edsono/1098157 to your computer and use it in GitHub Desktop.
EM automove after download complete...
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'fileutils' | |
require 'eventmachine' | |
trap("INT") do | |
EM.stop | |
end | |
EM.run do | |
EM::add_periodic_timer(3) do | |
Dir['~/downloads/*'].each do |filename| | |
basename = File.basename(filename) | |
case basename | |
when /^Castle.*/ | |
FileUtils.mv(filename, File.join('~/series/Castle', basename)) | |
else | |
FileUtils.mv(filename, File.join('~/movies', basename)) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very good! :D