Skip to content

Instantly share code, notes, and snippets.

@kalabiyau
Created August 24, 2011 11:57
Show Gist options
  • Save kalabiyau/1167911 to your computer and use it in GitHub Desktop.
Save kalabiyau/1167911 to your computer and use it in GitHub Desktop.
#!/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