Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Change creation date of a file

Hi guys!

I have a Digital Video File ending in .dv on an old CD. The file was created in on the 4th of September 2009 at 10:26 PM. I've converted the file to an .MP4. Now the file shows that it was created today, the 4th of November 2019. I want the file to indicate that it was create on the 4th of September 2009 at 10:26 PM. So I open up the terminal and I type touch -t 200709042226 then I drag the file on the terminal app and I get this result: MacBook-Pro:~ Samuel$ touch -t 2007090042226 /Volumes/PHOTOS/Video00001.mp4 

Then I press enter. This command is supposed to change the creation date of the file, but it only change the modified date. I've read somewhere that in order to be able to change the creation date, the creation date must be older than the modification date (Something like that). Since the modified date of Video00001.mp4 was today, changing the date to the 4th of September 2009 at 10:26 PM should work. Instead, I'm just changing the modified date of the file. Can someone tell me what I'm doing wrong? Thanks for your advise!

MacBook Pro 13", macOS 10.13

Posted on Nov 4, 2019 9:06 AM

Reply
Question marked as Best reply

Posted on Nov 4, 2019 10:13 AM

SetFile -d “09/04/2009 20:26:00” /Volumes/PHOTOS/Video00001.mp4


Those are (should be) vertical double quotes, not the right- or left-double-quotes.


https://ss64.com/osx/setfile.html


I’d probably also quote the file specification if you’re going to be scripting this, as that avoids the escaping.

Similar questions

14 replies
Question marked as Best reply

Nov 4, 2019 10:13 AM in response to Samuel Campeau

SetFile -d “09/04/2009 20:26:00” /Volumes/PHOTOS/Video00001.mp4


Those are (should be) vertical double quotes, not the right- or left-double-quotes.


https://ss64.com/osx/setfile.html


I’d probably also quote the file specification if you’re going to be scripting this, as that avoids the escaping.

Nov 4, 2019 11:46 AM in response to Samuel Campeau

The 'touch' command DOES NOT know about the Creating Date!


The touch command can change the

  • Change file date (used to indicate that file metadata was changed) Internally called ctime
  • Modification date (used to indicate file data was changed) Internally called mtime
  • Read date (used to indicate the file was opened for read access) Internally called atime

These are all standard Unix file timestamps. Unix does not have a file creation time.


macOS added a Creation time, but the touch command does not know about it.


MrHoffman

has the correct approach using the SetFile command.

Nov 4, 2019 9:30 AM in response to Limnos

Thank Limnos. This is the website I found my information. The results are just changing the modification date and not the creation. Once, I manage to change the creation date of a file, but for a reason, some files refuse to get there creation date change. This is what I'm after; What is making this file not allowing me to change the creation date using touch -t

Nov 4, 2019 10:16 AM in response to Samuel Campeau

Although the touch -r works to apply the creation and modification dates between an older and newer document, it only apparently applies the modification date between old and new video files. I just tested this with an older .mkv and newer .mp4.


I believe if you change the single quotes to double quotes, your SetFile command will work — provided that /Volumes/PHOTOS is not a read-only mount point.

Nov 4, 2019 11:10 AM in response to Samuel Campeau

Here’s the skeleton of a shell script as a starting point:

https://apple.stackexchange.com/questions/197895/how-to-do-a-batch-change-shift-of-file-creation-date


Tweak that to meet your needs, as you learn more about shell scripting...


The following (untested! brute-force!) bash code should be pretty close ro what you want, for files in the default directory (cd to that location) beginning with the string DSC_:


#!/bin/bash
for f in DSC_*.*; do
    SetFile -m "your-date-spec-here" "$f"
    SetFile -d "your-date-spec-here" "$f"
done


From the GUI, BBEdit (the free version is what replaced TextWrangler) is one of the text editors that can create a plain-text file, and which is the format you will need here when creating this file. The command-line editor nano (pico) will also work, among other options.

Nov 5, 2019 4:17 AM in response to BobHarris

Nothing quite like walking down a primrose path of wrongness about touch -r. For some reason, I mentally blotted out SetFile.


For the first time, Apple is including a watered down Python 3 distribution in either Xcode 11, or the Command Line Tools for Xcode 11. If one has not installed Xcode 11, or any third-party Python 3 distribution, then one can simply type on the command line in Catalina 10.15.0/1:


python3


and Catalina will prompt if you want to install the Command Line Tools for Xcode 11. When you do, you have spared 8GB of storage from the full Xcode 11 installation and now have /usr/bin/SetFile installed.


The following two command line invocations would apply the modification date and the birth (creation) date of the original file to the target file in the quoted format that SetFile expects:


SetFile -m "$(stat -t '%m/%d/%Y %T' -f '%Sm' srcfilepath)" destfilepath
SetFile -d "$(stat -t '%m/%d/%Y %T' -f '%SB' srcfilepath)" destfilepath


Change creation date of a file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.