C
Cory Wilkerson
Purpose here is to find all files > 5 hours old in a directory and wipe
them...
Of course I could just write a shell script but I wanted to leverage
ruby...or, rather, needed to leverage ruby...not real familiar with the
File and FileUtils API just yet...
dir_path = "~/foo/bar"
Dir.new(dir_path).each {|file|
if file.include?('foobar')
afile = File.new("#{dir_path}/#{file}")
if (Time.now - afile.mtime)/60/60 > 5
File.delete("#{dir_path}/#{file}")
end
end
}
them...
Of course I could just write a shell script but I wanted to leverage
ruby...or, rather, needed to leverage ruby...not real familiar with the
File and FileUtils API just yet...
dir_path = "~/foo/bar"
Dir.new(dir_path).each {|file|
if file.include?('foobar')
afile = File.new("#{dir_path}/#{file}")
if (Time.now - afile.mtime)/60/60 > 5
File.delete("#{dir_path}/#{file}")
end
end
}