https://github.com/whalemonkey/truncanator
Fork of ssokolow/trunc_filenames, extended with fixes and new features using DeepSeek R1 and Claude
https://github.com/whalemonkey/truncanator
cli file-rename file-renamer rust rust-lang utility
Last synced: 3 months ago
JSON representation
Fork of ssokolow/trunc_filenames, extended with fixes and new features using DeepSeek R1 and Claude
- Host: GitHub
- URL: https://github.com/whalemonkey/truncanator
- Owner: whalemonkey
- License: mit
- Created: 2025-01-24T01:57:49.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-05-01T13:52:40.000Z (5 months ago)
- Last Synced: 2025-05-06T22:32:51.461Z (5 months ago)
- Topics: cli, file-rename, file-renamer, rust, rust-lang, utility
- Language: Rust
- Homepage:
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# truncanator
Fork of the [trunc_filenames](https://github.com/ssokolow/trunc_filenames) program by [ssokolow](https://github.com/ssokolow) that aims to extend the code and add new features.
**Full disclosure:** the code written to extend this program is AI-generated using DeepSeek-R1. Though I am dogfooding this same code, __you use this at your own risk__.
## Synopsis
```
$ ./trunc_filenames --help
Rename files and directories to fit length limits.Preserve secondary extensions up to N characters (default: 6) using --secondary-ext-len. Set to 0 to disable extension preservation.
Usage: trunc_filenames [OPTIONS] [PATH]...
Arguments:
[PATH]... Paths to rename (recursively, if directories)Options:
--max-len Length to truncate to. (Default chosen for rclone name encryption) [default: 140]
-n, --dry-run Don't actually rename files. Just print
-s, --secondary-ext-len Maximum length to preserve for secondary extensions (e.g. 3 for ".tar" in ".tar.gz"). Set to 0 to disable [default: 6]
-w, --word-boundaries Respect word boundaries when truncating
-h, --help Print help
-V, --version Print version
```## Current shortcomings
*Note: this was initially written by the original author*
1. Requires a POSIX platform because I didn't want to do something hacky and
then forget, so I only bothered to implement "the length we care about is the
_encoded_ length" based on `std::os::unix::ffi::OsStrExt`.
2. ~~Doesn't preserve secondary extensions like the `.tar` in `.tar.gz`~~ Fixed in Truncanator
3. If the file/directory name already contains bytes that aren't valid UTF-8, it
won't bother to ensure that the truncation falls on the boundary between
valid UTF-8 code points.All of these are because it was a quick itch-scratch I would normally write in
Python and not even revision-control or upload, it works well enough for the
problem it was meant to solve, and solving any of those would have a
significantly lower return on investment.