Skip to content

Instantly share code, notes, and snippets.

@edsono
Created July 21, 2011 20:44
Show Gist options
  • Save edsono/1098157 to your computer and use it in GitHub Desktop.
Save edsono/1098157 to your computer and use it in GitHub Desktop.
EM automove after download complete...
#!/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
@hallison
Copy link

Very good! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment