3

Here is my use case but the question is a general one: how to duplicate a folder and preserve the Date Added info.

My Downloads folder is set to Group By and Sort By Date Added. I'd like to clean the contents of the Downloads folder by moving the files in it to a new folder and I'd like to preserve the Date Added info and view. So I thought I’d just duplicate the Downloads folder before cleaning it.

I've tried cp -a ~/Downloads/* newfolder, as mentioned here, ditto, tar, rsync, and Finder. In all cases, the new folder contains all files but they appear as having been added today. Only Duplicate in the Finder preserves the view setting in the new folder, but not the Date Added info.

I've also tried copying ~/Downloads/.DS_Store to the new folder before opening it in the Finder but it does not help.

How can I preserve Date Added when duplicating a folder?

9

1 Answer 1

2

At the outset I would like to say that I think this is an important question if only because it highlights a misunderstanding about Date Added. And this misunderstanding has not, to my knowledge, been addresses adequately in Ask Different.

Further, I am making this answer to explain why I don't consider Date Added to be metadata belonging to a file. And that is is spite of mdls and Finder presenting it as file metadata.

Consider a file which exists in two folders using a hardlink. The date added is then different for each apparent instance of the file.

Hence the Date Added metadata can't belong just to a file. It pertains to a conjunction of file and folder.

To put it another way, create a hard linked second instance of a file in a different folder. The two instances of the file will correctly have different Date Added values even though they are the same file on the disk.

So Date Added of a file is meaningless without including the folder.

Just to add to the above, here is a sequence that would lead to a nonsensical situation. Consider: 1) a file added to your Downloads folder 2 weeks ago; 2) create a new folder (creation date would be today); 3) move the file from the old to new folder preserving (if you could) the old date added. Now you have a file which was added to the new folder 2 weeks before the folder was created!!

Putting it very firmly, Date Added only has meaning as the date when a file was added to its present folder. Make a hardlink, move a file or folder, or duplicate a folder and the Date Added (of file to folder) must be different.

Any hack to avoid this is always going to be hack. The only known hack that I have found involves modifying the system date and whilst that is ingenious, I really don't think it is to be recommended.

4
  • “Date Added metadata can't belong just to a file.” — this is clear from the start. “It pertains to a conjunction of file and folder.” — exactly. Why can’t this metadata be preserved when duplicating a folder and its contents?
    – lhf
    Commented Aug 23, 2023 at 9:47
  • Anyway, thanks for the answer. I’ve given up trying to do this.
    – lhf
    Commented Aug 23, 2023 at 9:48
  • @lhf, When a folder is duplicated, the duplication is a new folder with a new Date Created (now) with all files inside as added to the new folder with Date Added as now.
    – Gilby
    Commented Aug 23, 2023 at 9:53
  • @lhf, what you may want is Date Downloaded. This is file metadata stored as an extended attribute of downloaded file and is preserved. It is visible in mdls, but not as a Finder column or sort term.
    – Gilby
    Commented Aug 23, 2023 at 9:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .