Project: Uniqopy
I just published a little tool for giving files unique names. It's written in Rust; you can find the source code on GitHub.
The idea of this tool is to copy a file, giving the copy a new name that will be
unique every time. Any time you might be giving files names like
file-version2-final.txt
, you could use uniqopy instead.
The tool's goals are:
- Simplicity: no surprises, no parameters to learn.
- Human-readable: the names of copied files are intended for human consumption.
- Unique names in time and content: The copied file's name should reflect when the file was copied and what its contents were.
Non-goals are:
- Efficiency: Files are copied, not renamed, so uniqopy probably isn't suitable for use with huge files.
- Security: Nobody should be relying on uniqopy for any kind of security guarantee. I'm not qualified to write security software, and provide useful security primitives is notoriously difficult.
With these in mind, I made the following decisions:
- Add a timestamp and a hash of the file contents to the copied file's name.
- Use current local time for the timestamp, on the assumption that whoever is reading the timestamp is the same person who generated, or at least knows what their timezone is.
- Use MD5 to hash the content, which is known to be insecure. Hopefully this will dissuade anyone who might think about using the hash for security.
The whole thing is less than a hundred lines of code with a dozen dependencies (most of which come from chrono). Cargo (Rust's packaging and build too) continues to be delightfully easy to use, so uniqopy is published to Crates.io. If you've already got Rust you can install uniqopy with
cargo install uniqopy
and take it for a spin.