back to notes

How to change a file creation, modification, access dates of a file

#
# creation date
# mtime: last modified date (modification: last file write)
# atime (access: last file read)
# ctime: change time (cannot be changed with touch because FS specific)
#
# setfile man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/SetFile.1.html
#
# Source: https://forums.macrumors.com/threads/touch-wont-change-file-creation-date-why.1969185/?post=22833415#post-22833415

# Change file creation date on Mac
# setfile -d 'MM/DD/YYYY HH:MM[:SS]" file
setfile -d "12/31/2020 23:59:59" file

# Change mtime: last modified date
# touch -m -t "YYYYMMDD HHMM" file
#
touch -m -t "20201231 2359" file

# Change mtime and atime
# touch -t "YYYYMMDD HHMM" file
#
touch -t "20201231 2359" file


last updated february 2020