Created
November 25, 2012 14:49
-
-
Save rubyginner/4143812 to your computer and use it in GitHub Desktop.
Organize your downloads
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
require 'fileutils' | |
path = '/Users/rubyginner/Downloads' | |
docs = ['.pdf', '.epub', '.txt', '.rtf'] | |
pics = ['.png', '.gif', '.jpg', '.jpeg','.bmp', '.JPEG', '.JPG'] | |
music = ['.mp3', '.wav'] | |
videos = ['.mp4', '.wmv', '.flv', '.mov', '.mpeg'] | |
apps = ['.dmg', '.pkg'] | |
archive = ['.zip', '.tar'] | |
Dir.foreach(path) { |dlfile| | |
next if ['.', '..'].include? dlfile | |
FileUtils.mv dlfile, path + '/Books' if docs.include? File.extname(dlfile) | |
FileUtils.mv dlfile, path + '/Pics' if pics.include? File.extname(dlfile) | |
FileUtils.mv dlfile, path + '/Music' if music.include? File.extname(dlfile) | |
FileUtils.mv dlfile, path + '/Videos' if videos.include? File.extname(dlfile) | |
FileUtils.mv dlfile, path + '/Apps' if apps.include? File.extname(dlfile) | |
FileUtils.mv dlfile, path + '/Archive' if archive.include? File.extname(dlfile) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't tried your script, but I find the following things you might want to try:
Anyhow, great work! Very creative! Keep it up!