Change The Creation Date of a File

You can alter the creation date of a file using the touch command in the Terminal. This can come in handy if you want to export a photo and have the creation date match the date the photo was taken.
Video Transcript / Captions
Closed captioning for this video is available on YouTube: Change The Creation Date of a File.

On this episode let me show you how to change a creation date of a file. But first let me show you why you might want to do that.

Here I am in Photos and I've selected a photo. I'm going to use Command I to get info on that photo and I see it was created on July 17, 2014. That was the exact time that the photo was taken.

However if I were to go to File, Export and export a photo and say I'm going to do it as a small photo, as a jpeg. I'm going to export it and put it on the desktop and now I get this file here on the desktop. If I select that file and use Command I to get info on that file you can see that the file was created today. But the photo was taken in 2014 and I'd like the file creation date to actually be the same as the date that the photo was taken. At least in this case. So how can I do that?

To do this I'm going to use the Terminal. You can find the Terminal app by going to Launchpad, searching for Terminal, and running it. Then I'm going to use a command called Touch. So, Touch and then space dash T. This means to change the time stamp or the creation time.

I'm going to type the time and I'm going to use a format like this: 20140717 July 17. I have to put the zero in front of the 7. That's important because it has to be a standard number of digits. I'm also going to look here and peek at the Photos app and see that it was taken at 7:33 pm.

So I'll go back to Terminal there and 7:33 pm would be the hour 19, since it's pm, and 33. 201407171933. Then I'm going to put the file name. Now I don't have to worry about the path to the file here or all that because I can drag and drop. Drag and drop inserts the full path /Users/macmost/desktop/IMG and the file. Then I now have the complete command her touch -t then the time formatted perfectly with leading zeros when needed, like 07 before the month, and the path to the file.

Now I'll go and check this file here. Command I and sure enough when I look it now says created on July 17, 2014 at 7:330 pm.

Comments: 2 Responses to “Change The Creation Date of a File”

    2 years ago

    Created is not changing for me. Only the Modified date.

    2 years ago

    The creation date is not a file property in the unix file system. It is, however, contained in the HFS file metadata. It can be set with the SetFile utility which can be found in the Xcode developer tools.

Comments Closed.