class Filesorter::Main
Public Instance Methods
get_all_paths()
click to toggle source
# File lib/filesorter.rb, line 21 def get_all_paths Path.new.get end
get_path(file)
click to toggle source
# File lib/filesorter.rb, line 25 def get_path(file) paths = get_all_paths case File.extname(file) when ".png", ".jpg", ".gif" then paths["picture"] when ".flv", ".mp4", ".vob", ".avi" then paths["video"] when ".mp3", ".wma", ".wav" then paths["music"] end end
media?(file)
click to toggle source
# File lib/filesorter.rb, line 34 def media?(file) extensions = [".png", ".gif", ".jpg", ".flv", ".mp4", ".vob", ".avi", ".mp3", ".wma", ".wav"] extensions.include? File.extname(file) end
move()
click to toggle source
# File lib/filesorter.rb, line 9 def move settings unless File.file?("#{Dir.home}/filesorter_settings.json") count = 0 Dir.foreach(".") do |file| if media?(file) path = get_path(file) count += 1 if system "mv \"#{file}\" #{path}" end end puts "#{count} files moved" end
settings()
click to toggle source
# File lib/filesorter.rb, line 5 def settings Path.new.set end