5

OS X keeps the date and time a file was added to the folder it's currently in, which is useful for sorting. Does any Unix/Linux filesystem or program offer similar functionality?

This is not a duplicate of How do I do a ls and then sort the results by date created? because I'm asking about the date it was added to the folder, not created. If it's moved somewhere else, the time gets reset.

2 Answers2

2

Yes though the details will vary wildly, whether by extending stat(2) (what macOS does, when _DARWIN_FEATURE_64_BIT_INODE is defined) or instead placing that information into extended file attributes, or somewhere else. For example NFSv4 as detailed in RFC 7530 mentions

5.8.2.36.  Attribute 50: time_create

   The time of creation of the object.  This attribute does not have
   any relation to the traditional UNIX file attribute "ctime"
   ("change time").

or for filesystems via some quick searching there is

btrfs otime
Ext4 crtime
UFS2 st_birthtime
ZFS crtime

though again the interfaces to such and whether a particular library or software product used supports such will vary wildly.

thrig
  • 34,938
  • 2
    Well, wouldn't that be file creation time, not date added time? – SilverWolf Oct 19 '17 at 19:57
  • what's the difference between the file creation time, and the date added time? – thrig Oct 19 '17 at 20:08
  • File creation time, AFAIK, is the date it was first created. Date added time, on the other hand, is the time it was last moved. (Simple renames don't seem to count.) – SilverWolf Oct 19 '17 at 20:09
  • Okay, what's a simple rename (is there some complex rename I don't know about?) and why don't they seem to count? How is "date added time" different from the creation time on the one hand, or the usual mtime/ctime/atime fields? – thrig Oct 19 '17 at 20:42
  • 1
    A "simple rename" is just renaming a file without moving it to a different folder (directory). The "date added time" is the time it was last moved to a different folder, even if it wasn't modified at all. Does the creation time change when moving the file? – SilverWolf Oct 19 '17 at 20:52
0

No, Linux does not have the "Date Added" feature.

In MacOS, "Date Added" is the timestamp of when a file was added to a directory. Linux simply doesn't have that information.

Linux (eg. ext4) has ctime (when file permissions or ownership was changed), mtime (when the actual file contents were changed), atime (file last opened), and crtime (birthdate of the file).

Moving a file to a different directory in Linux does not have a recorded time. (If the file is moved to a different file system altogether, that will update the ctime. But moving across directories mounted on the same file system doesn't update ctime. And primarily, ctime gets updated for other things instead.)

"Date Added" is a MacOS unique feature; it is not the "creation time". It is the "file moved" time. Sorry but you're out of luck on Linux.

Too bad, it is much more useful feature than "creation time" aka "birthdate".

cstacy
  • 1