How to Change File Modified Date on All Files to Midnight

Bit of an obscure one, but I searched Google without finding a specific example.

After back up, I want to set all my files in a given directory to be modified at midnight of the current day. The real modified date is not very important to me, so this command suffices. I have a specific reason for this process, though it’s quite unusual.

Anyway, here goes:

find . -type f -exec touch -t $(date +%Y%m%d0000) {} +

As ever, use with caution / practice on a copy of your data first.

Published by

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

Leave a Reply

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.