0

I'm on macOS Sierra. I'd really love to know how to use terminal to set the date modified of all .DS_Store files in a specific hierarchy to a given date.

So far, I know that I can do this:

sudo touch -t 200001010101 ./.DS_Store

That will set the date modified of the .DS_Store file in the current directory to 01/01/2000 01:01 AM. But I need to find a way to do this not just for the current directory, but all subfolders within that directory as well.

I seriously hope there is a simple solution for this. I'm sick to death of the date modified of various folders on my system being changed simply because of view changes I make in Finder when browsing them!

This question is about a smaller part of a larger task I'm trying to accomplish. I've almost got it all working now except part of the script that only seems to work when I run it from terminal directly. Here's a link to the main issue in case anyone reading this might be able to help: Service to execute series of commands on selected folders to eliminate issues with .DS_Store files in Finder

MikMak
  • 2,169

1 Answers1

1

If you use bash you can try something like:

sudo touch -t 200001010101 **/.DS_Store

This command will change the timestamp of .DS_Store in all subdirectories

More universal way is to use command like:

find . -name .DS_Store -type -f -exec touch -t 200001010101 {} \;

P.S. You may need to set this shopt -s dotglob if it's not already set.

Romeo Ninov
  • 7,848