File creation date in Ruby on Macs
Brent Simmons posted about how to get the file creation data in Ruby on a Mac. His solution is good, but suffers from shell injection. Here’s a slightly modifed version that’s not susceptible (that I know of):
require 'open3'
require 'time'
def creation_time(file)
Time.parse(Open3.popen3("mdls",
"-name",
"kMDItemContentCreationDate",
"-raw", file)[1].read)
end