Skip to content

Instantly share code, notes, and snippets.

@natan
Last active October 11, 2015 05:17
Show Gist options
  • Save natan/3808307 to your computer and use it in GitHub Desktop.
Save natan/3808307 to your computer and use it in GitHub Desktop.
Move everything on your desktop into ~/Dropbox/Documents/Desktops/<yyyy-mm-dd>/
#!/usr/bin/env ruby
require 'FileUtils'
require 'date'
def create_dir_if_necessary(path)
Dir.mkdir(path) unless File.directory?(path)
end
desktops_path = File.expand_path("~/Dropbox/Documents/Desktops")
create_dir_if_necessary(desktops_path)
today = Date.today.strftime('%Y-%m-%d')
today_path = File.expand_path("#{desktops_path}/#{today}")
create_dir_if_necessary(today_path)
FileUtils.mv(Dir.glob(File.expand_path("~/Desktop/*")), today_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment