Crates.io | timetime |
lib.rs | timetime |
version | 0.1.0 |
source | src |
created_at | 2021-10-26 23:36:11.601696 |
updated_at | 2021-10-26 23:36:11.601696 |
description | A CLI for repairing timestamp metadata of file copies ππ§πππππ |
homepage | |
repository | https://github.com/smudge/timetime |
max_upload_size | |
id | 472260 |
size | 29,304 |
A CLI for repairing timestamp metadata of file copies ππ§πππππ
When given two or more files, timetime
will cross-check their
created/modified timestamps and π
repair β¨ each file's timestamp metadata to
match whichever values are the earliest:
timetime my-file.txt backups/my-file.txt
By default, π¨the files must have identical checksumsπ¨, because it assumes
that they are copies. If not, a warning will be produced and the operation will
fail. This can be circumvented with the --force
or -f
option:
timetime --force file-1 file-2 file-3
β οΈUse with cautionβ οΈ, as this will blindly overwrite any number of timestamps!
By default, timetime
will compare both mtime
("modified at") and, on
supported systems, btime
("created at").
To compare only the "modified" timestamp, use the --mtime
or -m
flag:
timetime --mtime file-1 file-2
Note that some filesystems will prevent a file's "created at" from being after
its "modified at" by automatically setting btime
to match mtime
.
When supplied with multiple files, timetime
can be configured to use the
newest timestamps, rather than the oldest:
timetime --strategy newest file-1 file-2
This can be useful in situations where a set of files are known to be in the wrong timezone, or to have had their timestamp metadata damaged in some other way.
As a special feature, timetime
will detect if the files' timestamps are off
by an exact number of hours. If this is the case, it will output a warning:
Warning: files may have matching timestamps from different timezones
Due to the risk of false positives, this warning will not halt execution,
unless an extra --tz-safety
parameter is supplied:
timetime file-1 file-2 --tz-safety
rmlint
The timetime
command is intended to be used as part of a more complex file
consolidation and/or deletion script, such as one produced by rmlint
.
For example, prior to removing a duplicate file, it may make sense to "correct"
the timestamps of the files, to preserve the oldest modified/created
timestamps. This can be done by supplying a custom removal command to rmlint
:
rmlint -o sh -c sh:cmd='timetime --tz-safety "$1" "$2" && rm "$1"' --keep-all-tagged --must-match-tagged -T df /media/backup // /media/original
The above command will detect files in /media/backup
that are identical to
files in /media/original
, then "repair" timestamps across both the backup and
the original, and then (only if that succeeds) remove the duplicate file.
As always, be sure to test operations carefully before removing files en masse!
Set up Rust/Cargo and install from crates.io by running:
cargo install timetime
rmlint
for such a reliable and well-documented projectcargo build
) and functionality still works as expected.Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.