This is my workpace. It is grouped by date to help me orient in it.


Some of the folders group other projects by a company, for example. The problem is that file changes in those folders don't propagate to the container folder and even though there are projects that I have worked on recently, the folder will remain buried in history.

I would like to have a solution that will track those changes (1 level deep is sufficient) and touch the parent containers.

How to write a script that listens to the changes and does what I want?

I am on windows 10, but I use unxutils in cmd, bash and ubuntu wsl.

/edit I have just realised that the script doesn't have to listen to the changes but can run automatically every n hours - if that would make things easier.

  • 2
    In Linux, you can set the modify stamp of a directory to the time stamp of its more recent child with touch -r $(ls -t | head -1) . (yes, you can touch a directory). – xenoid Apr 10 '19 at 12:11
  • Excellent, I can totally do that in cmd with UnxUtils or with git for Windows, thanks! – Qwerty Apr 10 '19 at 12:45

Thanks @xenoid for the heads up. This is ultimately my solution

for d in */; do
    touch $d -r "$d$(ls $d -t | head -1)"

Now I just need to figure out how to run it automatically. I'll get back and update this answer...

  • I didn't manage to run it automatically, but it doesn't matter, I just double-click touch.sh in the folder and it's updated whenever I feel it's out of sync. – Qwerty Mar 30 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.