C
Clement Ow
I have a script which I need to create a new Time or Date object to
compare 2 dates for deletion. ie to delete files older than a stipulated
date
But i tend to get this error, undefined method 'parse' for
DateTime:class or undefined method 'strptime'
Can anyone tell me what is wrong? A snippet of my code is as follows:
compare 2 dates for deletion. ie to delete files older than a stipulated
date
But i tend to get this error, undefined method 'parse' for
DateTime:class or undefined method 'strptime'
Can anyone tell me what is wrong? A snippet of my code is as follows:
folders.each do |folder|
Dir.glob(folder+"/*") do |file|
match = regexp.match(File.basename(file))
match1 = regexp1.match(File.basename(file))
matchExp = excep_yyyymmdd.match(File.basename(file))
matchExp1 = excep_ddmmyyyy.match(File.basename(file))
if match
file_date = DateTime.strptime(match[1])
if matchExp != nil or matchExp1 != nil
if $keepLastMthDay == true or $keepLastMth == true
puts "File Escaped: #{file} (Keep last day of month option >activated)"
elsif $keepLastMthDay == false and $keepLastMth == false
if delete_date > file_date
size = (File.size(file))/1024
deleted_files << fileData.new(file,size)
puts "Files/Folders deleted: #{file} size: #{size} KB"
#FileUtils.rm_r file
end #if
end #if
elsif matchExp == nil or matchExp1 == nil
if delete_date > file_date
size = (File.size(file))/1024
deleted_files << fileData.new(file,size)
puts "Files/Folders deleted: #{file} size: #{size} KB"
#FileUtils.rm_r file
end #if
end # if matchExp