Skip to content

Instantly share code, notes, and snippets.

@yanks
Last active August 29, 2015 14:13
Show Gist options
  • Save yanks/f6e640f82a3db07fe45f to your computer and use it in GitHub Desktop.
Save yanks/f6e640f82a3db07fe45f to your computer and use it in GitHub Desktop.
Move day-old files off your desktop
#!/usr/bin/env ruby
now = Time.now
desktop = File.expand_path("~/Desktop")
Dir.entries(desktop).each() do |file|
if file.start_with?(".") || file.start_with?('Graveyard') then
next
end
ftime = File.atime("#{desktop}/#{file}")
if (now.to_i - ftime.to_i > (60*60*24)) then
`mv ~/Desktop/#{file} ~/Desktop/Graveyard/#{file}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment