Set the Creation and Modification Date of a File in OS X Using the Terminal


Sometimes you have to change the creation or modification date of a file, for example, when you edit old images in your personal photo library, the date will change to the current one. And that can cause the edited photos to show up in your photo library as newer items.

You can use the OS X developer tool SetFile on the command line to change a file's creation or modification date, but you must first install the developer tools (Xcode) from the OS X installation media, or by download from the Mac App Store. SetFile can be found in the /usr/bin/ directory in Mac OS X 10.5 and later.

Below is the format of the command call using Terminal.

sudo cd /Developer/usr/bin/
./SetFile -d '10/29/2011 12:00:00 PM' /path/nameoffile.txt

One trick you can use to add the filename to the command is to enter everything through the date, and then drag-and-drop the file onto the Terminal window and it will append the path and filename to the command line.

You can use another program calledGetFileInfoto obtain the modification date.

sudo cd /Developer/usr/bin/
./GetFileInfo /path/nameoffile.txt

Michael directs all design initiatives, heads marketing, and builds cool software for Fynydd. He's also a husband, father, avid reader, advocate for reason and science, and autodidact.

Fynydd is a software design and development company that creates awesome user experiences for all kinds of devices. Our expertise has helped people to do things like:

  • Create a new product or service.
  • Automate processes and workflows.
  • Bring a mobile strategy to life.
  • Better interact with their customers.

How can we help you? Contact us and let us know.