Created
October 3, 2011 22:37
-
-
Save edsono/1260449 to your computer and use it in GitHub Desktop.
Automove files to right 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'fileutils' | |
series = {} | |
Dir['/home/xbmc/series/*'].each do |dirname| | |
series["^#{File.basename(dirname).downcase}.*"] = dirname | |
end | |
Dir['/home/xbmc/download/*'].each do |filename| | |
basename = File.basename(filename).downcase.gsub("\.", '') | |
series.keys.each do |regex| | |
re = Regexp.new(regex) | |
FileUtils.mv(filename, series[regex]) if re =~ basename | |
end | |
FileUtils.mv(filename, '/home/xbmc/movies') if File.exist?(filename) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment