Last active
August 29, 2015 14:10
-
-
Save androidyue/30fbe5565d4ed22d9f09 to your computer and use it in GitHub Desktop.
A super tool to remove old files.
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
#!/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