Change a file’s creation/modified date on Mac OS X
This is a very simple guide on how to change a file’s creation date or last modified date attributes on Mac OS X. Based on Snow Leopard 10.6, this should work on previous versions of Mac OS X.
Date Format Key:
YYYY – The year (the first two digits/century can be omitted)
MM – The month of year, from 01 to 12
DD – The day of the month, from 01 to 31
hh – The hour of the day, from 00 to 23
mm – The minute of the hour, from 00 to 59
Creation Date – Single file
How to change the creation date attribute of a single file:
Note: changing the creation date attribute will also change the modified date attribute and set it the same as the creation date.
- Start the Terminal application (/Applications/Utilities/Terminal.app) or if you prefer use iTerm.
- Type the following in the command line, but do not hit enter/return. Replace YYYYMMDDhhmm with the desired date information:
touch –t YYYYMMDDhhmm
- Open a Finder window and locate the file you wish to modify. Drag and drop the file into the Terminal window, the file and path will be added to the end of the line you just typed.
Here is an example of what the line should look like:
touch –t 200005151125 /Volumes/Mac\ HD/Pictures/myfile.jpg
200005151125 in the example above represents 15th May 2000 11:25 AM.
- If all is in order press the enter/return key. The creation date should now be changed to the date specified above, as well as the last modified date.
Modified Date – Single file
How to change the last modified date attribute of a single file:
- Start the Terminal application (/Applications/Utilities/Terminal.app) or if you prefer use iTerm.
- Type the following in the command line, but do not hit enter/return. Replace YYYYMMDDhhmm with the desired date information:
touch –mt YYYYMMDDhhmm
- Open a Finder window and locate the file you wish to modify. Drag and drop the file into the Terminal window, the file and path will be added to the end of the line you just typed.
Here is an example of what the line should look like:
touch –mt 201006301525 /Volumes/Mac\ HD/Pictures/myfile.jpg
201006301525 in the example above represents 30th June 2010 3:25 PM.
- If all is in order press the enter/return key. The last modified date should now be changed to the date specified above.
Creation Date – Multiple files
How to change the creation date attribute of multiple files:
Note: changing the creation date attribute will also change the modified date attribute and set it the same as the creation date.
- Make sure all the files you want changing are in the top directory of the same folder. Do not place files in this folder if you don’t want them to be modified.
- Start the Terminal application (/Applications/Utilities/Terminal.app) or if you prefer use iTerm.
- Type the following in the command line, but do not hit enter/return. Replace YYYYMMDDhhmm with the desired date information:
touch –t YYYYMMDDhhmm
- Open a Finder window and locate the folder containing the files you wish to modify. Drag and drop the folder into the Terminal window, the folder and path will be added to the end of the line you just typed.
Here is an example of what the line should look like:
touch –t 201004270930 /Volumes/Mac\ HD/Pictures/Album
201004270930 in the example above represents 27th April 2010 09:30 AM.
- Add /* to the end of the command. If you’re only targeting a specific file type include its extension (e.g. /*.jpg). Your command should look something like this:
touch –mt 201004270930 /Volumes/Mac\ HD/Pictures/Album/*
or
touch –mt 201004270930 /Volumes/Mac\ HD/Pictures/Album/*.jpg
- If all is in order press the enter/return key. The creation date should now be changed to the date specified above, as well as the last modified date, for all the files within that folder.
Modified Date – Multiple files
How to change the last modified date attribute of multiple files:
- Make sure all the files you want changing are in the top directory of the same folder. Do not place files in this folder if you don’t want them to be modified.
- Start the Terminal application (/Applications/Utilities/Terminal.app) or if you prefer use iTerm.
- Type the following in the command line, but do not hit enter/return. Replace YYYYMMDDhhmm with the desired date information:
touch –mt YYYYMMDDhhmm
- Open a Finder window and locate the folder containing the files you wish to modify. Drag and drop the folder into the Terminal window, the folder and path will be added to the end of the line you just typed.
Here is an example of what the line should look like:
touch –mt 201006081015 /Volumes/Mac\ HD/Pictures/Album
201006081015 in the example above represents 8th June 2010 10:15 AM.
- Add /* to the end of the command. If you’re only targeting a specific file type include its extension (e.g. /*.jpg). Your command should look something like this:
touch –mt 201006081015 /Volumes/Mac\ HD/Pictures/Album/*
or
touch –mt 201006081015 /Volumes/Mac\ HD/Pictures/Album/*.jpg
- If all is in order press the enter/return key. The last modified date should now be changed to the date specified above, for all the files within that folder.
Hope you found this tutorial somewhat useful.
2 comments
Comment by laine
on August 16, 2010 at 7:29 pm
hello- i tried to change the modified date by using your steps. the date i tried is touch -mt 200905191235
i get the same error message no matter what i do:
touch: out of range or illegal time specification:
what do i do?
Comment by grapii
on August 18, 2010 at 11:55 am
The post was based on UK time format? which localisation is set on your mac? you may need to swap the dates from YYYYMMDD to YYYYDDMM