Skip to content

Instantly share code, notes, and snippets.

@androidyue
Last active August 29, 2015 14:10
Show Gist options
  • Save androidyue/30fbe5565d4ed22d9f09 to your computer and use it in GitHub Desktop.
Save androidyue/30fbe5565d4ed22d9f09 to your computer and use it in GitHub Desktop.
A super tool to remove old files.
#!/usr/bin/env ruby
# encoding: utf-8
#Usage: ruby removeOldFiles.rb "dest_file_pattern" days_ago
destFilePattern= ARGV[0]
daysAgo= ARGV[1]
edenTime = Time.now.to_i - daysAgo.to_i * 86400
Dir[destFilePattern].each{|child|
system "rm -rfv #{child}" if (File.mtime(child).to_i < edenTime)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment