rsdml: Humanising Last-Modified Timestamps
A small tool I wrote in Go to make timestamps in webserver directory indexes more intuitive and human friendly. Recursively Set Directory MTime to Latest.
Check it out here! https://github.com/michael131468/rsdml
When serving up a directory structure with Apache or Nginx, it’s possible to
show the last modified
timestamp (aka mtime). This is useful when trying to
indicate to users which files are newer or older.
There is one issue though and that is with directories. The last modified timestamp of a file is very intuitive, it’s when the file was last changed. But for a directory, the definition of when it changed is non-intuitive (at least in my opinion). Not all modifications to a directory will affect its mtime value and if files deeper in the directory tree are changed, the mtime value will only affect the immediate parent directory and not ripple upwards to its grandparents and so on.
So if you have newer files showing up deep in a directory tree structure, a user may not notice because navigating from the top parent directories will not show a hint of the newer timestamps.
That’s where rsdml comes into play. It will walk through a directory tree and change the mtime of directories to match the newest of its subdirectories. This way a user navigating from the top level will see the newer timestamps.
This can also be done with a bunch of shell scripting but I find it’s not very elegant compared to a simple cli tool. I hope this can be useful to anyone else who also fields complaints from their users about confusing timestamps!