Home Writing Reading

til / Change creation date of a file

MacOS’s built-in touch command can help us when we find ourselves in a situation where we need to update the creation or modification time of a file.

touch -t 202203301500 file.ext
  • -t - Update access, creation, and modification times. It only updates the creation time if the new time is before the current creation time.
  • 202203301500 - The new time, 2022-03-30 15:00. Format is CCYYMMDDhhmmSS.
    • If the century, CC, is not provided, it will default to 19 if the year, YY, is between 69 and 99, and 20 for any other year value.
    • SS defaults to 0.
  • file.ext - The file we want to modify

If we only want to change the modification time, we can use -m instead of -t.

I recently combined posts for this site from two different sources and used this command to correct the sort order, which is based on the post’s created time, and found this command very helpful.


  • Loading next post...
  • Loading previous post...