WordPress Developer & Linux Administrator

Changing the date & time of a file or files

Ever needed to quickly change the date and time of a particular file? The reasons for something like this might be endless, but a practical example might be forcing a file to copy out to another location via some automated scripts you have in place to deploy website changes, etc. I’ll be damned if I’m going to manually open, save, and close a file in order to modify its date/time stamp.

To change a single file, you can do so like this:


If you have multiple files, you could run that multiple times. However, if you’re wanting to force an entire directory to update with the new date/time changes, you could do this:

cd ./some/directory
find . -exec touch -t YYYYMMDDHHMM.SS {} +

This will find every file and directory in and below the current working directory, and any file or directory matches will receive the new date and time changes.

Categories: CommandsTags: , , , ,


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.