| Crates.io | dirstamp |
| lib.rs | dirstamp |
| version | 0.1.4 |
| created_at | 2025-08-04 11:07:39.148423+00 |
| updated_at | 2025-08-15 08:39:10.978881+00 |
| description | Sync a directory's modified time to its newest contained item. |
| homepage | https://github.com/Crinklebine/dirstamp |
| repository | https://github.com/Crinklebine/dirstamp |
| max_upload_size | |
| id | 1780598 |
| size | 34,293 |
dirstamp updates the modification timestamp of each folder so that it matches the newest file (or folder) directly inside it.
This is useful when migrating or restoring folders, as some operating systems and tools do not preserve folder timestamps accurately.
Example
You copy a folder on 2025-08-03, so Windows shows its Date modified as 2025-08-03. The newest file inside was actually last edited on 2024-07-28. After runningdirstamp -C, the folder’s Date modified is reset to 2024-07-28, matching that newest file.
dirstamp [PATH] [OPTIONS] (path and options order are interchangable)
If PATH is not specified, it defaults to the current directory.
| Flag | Description |
|---|---|
-C, --confirm |
Apply timestamp changes (dry-run is default) |
-D, --show-dates |
Show the human-readable timestamp each folder would be updated to |
-V, --version |
Show version info |
-h, --help |
Show usage info |
Example dry-run output with -D:
would update ".\\test\\dirstamp_test\\media\\photos" (from 2025-08-03 08:07:08 UTC to 2025-08-01 08:07:08 UTC, -2.0 days)
would update ".\\test\\dirstamp_test\\projects\\alpha" (from 2025-08-03 08:07:08 UTC to 2025-07-19 08:07:08 UTC, -15.0 days)
would update ".\\test\\dirstamp_test\\projects\\beta" (from 2025-08-03 08:07:08 UTC to 2025-07-31 08:07:08 UTC, -3.0 days)
would update ".\\test\\dirstamp_test\\docs" (from 2025-08-03 08:07:08 UTC to 2025-07-04 08:07:08 UTC, -30.0 days)
would update ".\\test\\dirstamp_test\\media" (from 2025-08-03 08:07:08 UTC to 2025-07-24 08:07:08 UTC, -10.0 days)
would update ".\\test\\dirstamp_test\\" (from 2025-08-14 13:46:06 UTC to 2025-08-03 08:07:08 UTC, -11.2 days)
Note: this was a dry run. Use -C to confirm and apply changes.
If no folders need updating:
No folder timestamps need updating.
| Feature | Description |
|---|---|
| File-first logic | Uses the newest file in a directory; if no files exist, it uses the newest subfolder. |
| Recursive | Processes the specified folder and all subfolders. |
| Dry run (default) | By default, runs without modifying anything. Shows what would change. |
| Show dates | Use -D or --show-dates to display the human-readable timestamp each folder would be updated to |
| Confirm mode | Use -C or --confirm to actually apply the timestamp updates. |
| Simple CLI | Easy to use, Unix-style tool. |
| Cross-platform | Works on Windows, Linux, and macOS. |
| Single binary | No runtime, no PowerShell execution-policy fuss—just run the EXE (or ELF/Mach-O). |
cargo install dirstamp
Requires Rust 1.70+:
git clone https://github.com/Crinklebine/dirstamp
cd dirstamp
cargo build --release
Run it from the build output:
./target/release/dirstamp(.exe)
For each directory (depth-first traversal):
mtime) of any file directly inside the directory (not recursively).mtime differs by more than 1 second:
mtime to match the newest file’s mtime.Notes:
If no files exist, the newest immediate subfolder is used instead.
Empty directories are left unchanged.
Only the modification time (mtime) is updated; creation or birth time remains untouched.
Changes are applied only with --confirm (-C). By default, it's a dry run.
Pull requests and issues are welcome!
cargo fmt
cargo clippy -- -D warnings
Please run the above before submitting.
Licensed under the MIT License – see LICENSE.