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.
for d in /"YourCompleteFilePathHere"/**/*(/); do touch -r $d/*(om[1]) $d; done.
The important part was to make sure the entire filepath was specified.
cd
ing 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