1

I would like to recursively update the Date Modified field of a directory (and all its subdirectories) so that every folder has the same Date Modified timestamp as the most recently modified file that is contained within the tree.

I have read and tried to utilise the detailed solutions posted here: How do I change folder timestamps recursively to the newest file? but am unable to get them to work.

I am using Mac OS.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Matt
  • 11
  • I finally managed to make the linked solution in zsh work: for d in /"YourCompleteFilePathHere"/**/*(/); do touch -r $d/*(om[1]) $d; done.

    The important part was to make sure the entire filepath was specified. cding into a directory does not change the path of where this script initiates.

    However, I find that I need to run the script multiple times for all folders to get updated (the folder tree is highly nested, so perhaps that is the problem). Cheers!

    – Matt Oct 19 '16 at 15:12

0 Answers0