Change File Created Date and Time using Mac Terminal Command


















If you have a file on your Mac and you want to change its created date and time (timestamp) then you can do that using the Terminal app as follows.

% ls -l | grep myfile.csv 

-rw-r--r--  1 c2ctechtv  staff      0 Sep  7 12:51 myfile.csv

Here, we have a file myfile.csv with the created date as September 7th at 12:51 hours.

Now let's change this date to 4th of July 2023 and time as 03:00 hours.

% SetFile -d '07/04/2023 03:00:00' myfile.csv

If you want, you can also create a file with a date for the future or past using the touch command and -mt flag.

Syntax:
touch -mt YYYYMMDDhhmm <file-name.extension>
Example:
touch -mt 202101010100 myfile.csv
Change File Created Date using Mac Terminal Example
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X





























Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap