Last active
December 11, 2015 05:49
-
-
Save aniketpant/4554948 to your computer and use it in GitHub Desktop.
The rules I use to organize my download folder
This file contains 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" | |
Maid.rules do | |
rule "debian packages" do | |
move(dir("~/Downloads/*.deb"), "~/Downloads/deb") | |
end | |
rule "compressed" do | |
move(dir("~/Downloads/*.(zip|tar.gz|rar|tar.bz2|tgz)"), "~/Downloads/compressed") | |
end | |
rule "PDFs" do | |
move(dir("~/Downloads/*.(pdf|mobi)"), "~/Downloads/pdfs") | |
end | |
rule "images" do | |
move(dir("~/Downloads/*.(jpg|jpeg|gif|png|eps)"), "~/Downloads/images") | |
end | |
rule "videos" do | |
move(dir("~/Downloads/*.(mkv|mp4|avi)"), "~/Downloads/videos") | |
end | |
rule "audio" do | |
move(dir("~/Downloads/*.mp3"), "~/Downloads/audio") | |
end | |
rule "screenshots" do | |
Dir.foreach("/home/aniket/Pictures") { | |
|filename| | |
fullpath = "/home/aniket/Pictures/#{filename}" | |
create_time = (/\w+-\w+-\w+[[:blank:]]\w+:\w+:\w+/.match(filename)).to_s | |
date = create_time.split[0].to_s | |
year = date.split("-")[0].to_s | |
month = date.split("-")[1].to_s | |
if year and month != "" | |
finalpath = "/home/aniket/Pictures/Screenshots/#{year}/#{month}" | |
FileUtils.mkdir_p(finalpath) | |
FileUtils.mv fullpath, finalpath | |
end | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment