Reading the actual file creation date on Mac OS with Perl
file, macos, perl
Solution
Simply read the output from the `mdls` command. You can always do something like:
perl -e '@lines = qx(mdls filename.txt); print "@lines[3]";'
or similar.
see `man mdls`
mdls -- lists the metadata attributes for the specified file
for creation date you should use:
mdls -raw -name kMDItemFSCreationDate filename
Ps: the module MacOSX::File::Catalog is developed for this, but unfortunately it is broken in Mountain Lion. (error during install - at least on my OS X)
Problem
I would like to read the creation date of a file as it is represented on the Mac OS Finder. This is part of my code: ``` require File::stat; use Time::localtime; ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($file_path); print ctime($ctime) . "\n"; ``` On the Finder, every file has two dates: created and modified. I assumed that `$ctime` would be equal to the "created" date from the Finder, but it is completely different. Doing some research, I found out that most Unix operating systems don't store this kind of date, however, Mac OS does. Does anybody know a way to read this information from a file?