I have a number of project folders that all got their date modified set to the current date & time somehow, despite not having touched anything in the folders. I'm looking for a way to use either a batch applet or some other utility that will allow me to drop a folder/folders on it and have their date modified set to the date modified of the most recently modified file in the folder. Can anyone please tell me how I can do this?
In case it matters, I'm on OS X Mavericks 10.9.5. Thanks!
If you start a Terminal, and use
statyou can get the modification times of all the files and their corresponding names, separated by a colon as follows:Sample Output
You can now sort that and take the first line, and remove the timestamp so you have the name of the newest file:
Sample Output
Now, you can put that in a variable, and use
touchto set the modification times of all the other files to match its modification time:So, if you wanted to be able to do that for any given directory name, you could make a little script in your HOME directory called
setModlike this:Then make that executable, just necessary one time, with:
Now, you can set the modification times of all files in
/tmp/freddyFroglike this:Or, if you prefer, you can call that from Applescript with a:
The
nameOfDirectorywill need to look Unix-y (like/Users/mark/tmp) rather than Apple-y (likeMacintosh HD:Users:mark:tmp).