From: "Multicom D." Date: 2011-11-22T19:27:25+09:00 Subject: Removing directories older than x days old Hi, I am trying to write a script that will remove directories that are older than 5 days old. I can't seem to get the datetime for the directory to be usable for comparison. require 'fileutils' class CleanupDirs def cleanup() Dir.foreach("/mydir/") do |entry| puts entry etime = File.stat(entry) vAgeInDays = ageInDays( etime.ctime ) if vAgeInDays > 5 Dir.delete(entry) end end end def ageInDays(days) ydate = Time.new ydate = ydate - ( 24 * 60 * 60 * days) return ydate end end CleanupDirs.new.cleanup I keep getting the error Time can't be coerced into Fixnum (TypeError). Can someone point out what I am doing wrong? TIA -- Posted via http://www.ruby-forum.com/.