Updating content creation date on macOS

Updating content creation date on macOS

My custom static site generator falls back to file creation dates when post creation date hasn't been specified in the metadata. On macOS, this is the Content Creation Date, and something I couldn't update with touch.

I occasionally need to change this date when copying a notebook file as a starting template for a new one.

Viewing the Content Creation Date

To view the ContentCreationDate, we can use the following command.

mdls -raw -n kMDItemContentCreationDate my-content-file.ipynb

The output of which may read something like the following.

2023-03-30 10:46:57 +0000% 

Set the Content Creation Date

To set the ContentCreationDate, we can use the following command.

SetFile -d "06/25/2023 23:59:59" my-content-file.ipynb

Note

The date is in the format mm/dd/yyyy.

With that, my static site generator can continue listing items in the desired order.

Comments

Stay up to date

Get notified when I publish something new, and unsubscribe at any time.