Created
August 24, 2011 11:57
-
-
Save kalabiyau/1167911 to your computer and use it in GitHub Desktop.
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/local/bin/ruby | |
require 'ap' | |
DOCS = %w{doc docx odt xls} | |
SCANS = %w{pdf tiff jpg jpeg bmp} | |
ARCHS = %w{zip rar 7z gz tgz bz2 bz} | |
MUZ = %w{mp3 wav flac} | |
dowsdir = '/home/achernikov/Downloads' | |
docs = [] | |
archs = [] | |
scans = [] | |
music = [] | |
puts "Processing #{dowsdir} directory" | |
files = Dir.entries(dowsdir) | |
puts "We have #{files.count} files in target dir" | |
files.map do |file| | |
{ "docs" => DOCS, "scans" => SCANS, "archs" => ARCHS, "music" => MUZ }.each do |name, const| | |
puts name.class | |
const.each {|d| name << file && files.delete(file) if file =~ /\.#{d}$/} | |
end | |
end | |
puts "We have #{files.count} files in target dir" | |
ap docs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment