Skip to content

Instantly share code, notes, and snippets.

@aniketpant
Last active December 11, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniketpant/4554948 to your computer and use it in GitHub Desktop.
Save aniketpant/4554948 to your computer and use it in GitHub Desktop.
The rules I use to organize my download folder
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