Created
September 23, 2014 17:16
-
-
Save cmar/34c4c8ebc4d6a9fe0b5b to your computer and use it in GitHub Desktop.
Dropbox Camera Uploads sorter
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
task :default do |task| | |
file_list = FileList['*.jpg', '*.png', '*.gif', '*.mov', '*.mp4'] | |
file_list.each do |file| | |
year = file[/^\d{4}/] | |
month = file[/(?<=^\d{4}-)\d{2}/] | |
directory = File.join year, month | |
mkdir_p directory | |
mv file, directory | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment