How can you find the most recently modified folder (NOT A FILE) in a directory using Ruby?
Dir.glob("a_directory/*/").max_by {|f| File.mtime(f)}
Dir.glob("a_directory/*/")
returns all the directory names in a_directory
(as strings) and max_by
returns the name of the directory for which File.mtime
returns the greatest (i.e. most recent) date.
Edit: updated answer to match the updated question