Created
November 22, 2013 17:59
-
-
Save stoplion/7604178 to your computer and use it in GitHub Desktop.
Desktop File and Folder cleanup automation written in Thor
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
| # Install on your system.. | |
| # thor install cleanup_folder.thor | |
| class Cleanup < Thor | |
| desc "Images", "Move images into Images folders" | |
| def images | |
| if Dir.exists?("Images") | |
| puts "Skipping Images, already a folder named Images" | |
| else | |
| FileUtils.mkdir("Images") | |
| end | |
| Dir.glob("*.{png,jpg,gif,jpeg}").each do |f| | |
| FileUtils.mv(f, Dir["Images"].to_s) | |
| end | |
| end | |
| desc "Bookmarks", "Move weblocs into Bookmarks folder" | |
| def weblocs | |
| if Dir.exists?("Bookmarks") | |
| puts "Skipping Bookmarks, already a folder named Bookmarks" | |
| else | |
| FileUtils.mkdir("Bookmarks") | |
| end | |
| Dir.glob("*.webloc").each do |f| | |
| FileUtils.mv(f, Dir["Bookmarks"].to_s) | |
| end | |
| end | |
| desc "Design_Files", "Move design files into Design_Files" | |
| def design_files | |
| if Dir.exists?("Design_Files") | |
| puts "Skipping Design_Files, already a folder named Design_Files" | |
| else | |
| FileUtils.mkdir("Design_Files") | |
| end | |
| Dir.glob("*.{ai,psd}").each do |f| | |
| FileUtils.mv(f, Dir["Design_Files"].to_s) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment