def delete_older(dir, time)
save = Dir.getwd
Dir.chdir(dir)
Dir.foreach(".") do |entry|
# We're not handling directories here
next if File.stat(entry).directory?
# Use the modification time if File.mtime(entry) < time
File.unlink(entry) end end
Dir.chdir(save) end