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

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

1 Posts
1 Users
0 Likes
1,183 Views
 Hans
(@hans)
Famed Member Admin
Joined: 10 years ago
Posts: 2547
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

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: