C
Clement Ow
I have my code which looks like this:
will run successfully. However, if the filename has additional
characters added to it, say, risk20080331, it'll run an error. And i
reckon it's the cause of the above line.
So is there any way I can extract the date using regex or whichever way
simpler so I can compare the deletion date and execute the rm_r command?
Thanks!
When my file name is in the format, 20080331 for example, the scriptdelete= 5 + 2 #escape counting in weekends i.e Sat,Sun
folders = $del_path
puts delete_date = DateTime.now - delete
regexp = Regexp.compile(/(\d{4}\d{2}\d{2})/)
fileData = Struct.newname, :size)
deleted_files = []
folders.each do |folder|
Dir.glob(folder+"/*") do |file|
match = regexp.match(File.basename(file));
if match
file_date = DateTime.parse(match[1])
will run successfully. However, if the filename has additional
characters added to it, say, risk20080331, it'll run an error. And i
reckon it's the cause of the above line.
So is there any way I can extract the date using regex or whichever way
simpler so I can compare the deletion date and execute the rm_r command?
Thanks!