Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



macOS/Linux - How t...
 
Share:
Notifications
Clear all

[Solved] macOS/Linux - How to change Modified of Created date and time of a file

1 Posts
1 Users
0 Reactions
1,491 Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2727
Topic starter  

Sometimes you need to modify the "modified" or "created" date of a file.
Terminal offers a way to do this with the "touch" command.

For this we need to write the date and time in a specific format:

YYYYMMDDhhmm

 

Where the characters need to be replaced with: 

YYYY   — Year in 4 digits
MM     — Mont in 2 digits (01 to 12)
DD     — Day of the month, in 2 digits, from 01 to 31
hh     — Hour of the day, in 2 digits, 24 hour notation, from 00 to 23
mm     — Minutes, in 2 digits, from 00 to 59

 

To change the modified date:

touch -mt 202103091446 MyFile

This will change the modified date of "MyFile" to 2021, March 9th, 14:46 (or 2:46 PM).

To change the created date:

touch -t 202103091446 MyFile

This will change the creation date of "MyFile" to 2021, March 9th, 14:46 (or 2:46 PM).

 


   
ReplyQuote
Share: