From: 7stud -- Date: 2008-02-07T07:50:30+09:00 Subject: Re: pulling elements into a method... grooveska wrote: > > Here is the part of the script I'm having problems with: > > time = Time.now #set time object to the current time > month = time.month #grab the number of the month from the > current > day = time.day #grab the day of the current time > year = time.year #grab the year of the current time > > day = day - 14 > def delete_old_files(dir, time) > Dir.chdir(dir) do > Dir.foreach(".") do |entry| > next if File.stat(entry).directory? #prevent from deleting > directories > > #Use the modification time > if File.mtime(entry) < time > File.unlink(entry) > end > end > end > end > > cleanup_dirs = ["E:/oracle/MB4/oraarch/", "E:/oracle/MB3/oraarch/", > "E:/oracle/MB5/oraarch", "F:/oracle/MBA/oraarch/", "F:/oracle/MB2/ > oraarch/", "F:/oracle/MB3/oraarch/", "F:/oracle/MB/oraarch/"] > cleanup_dirs.each do |cleanup_directory| > > delete_old_files(cleanup_directory,Time.local(year,month,day,00,00,0)) > > end > > > I should probably use a block or proc or something like that. Any > advice is greatly appreciated. I'm getting the argument out of range > error. > > Thanks. Pay attention to this code: day = day - 14 ... ... Time.local(year,month,day,00,00,0) -- Posted via http://www.ruby-forum.com/.