Minimal recursive "truncate file/directory names to meet requirements" tool

Overview

trunc_filenames

ssokolow@monolith ~ % trunc_filenames --help
trunc_filenames 0.1.0
Rename files and directories to fit length limits.

WARNING: Will not preserve secondary extensions like .tar.gz

USAGE:
    trunc_filenames [OPTIONS] [PATH]...

ARGS:
    <PATH>...    Paths to rename (recursively, if directories)

OPTIONS:
    -h, --help                 Print help information
        --max-len <MAX_LEN>    Length to truncate to. (Default chosen for rclone name encryption)
                              [default: 140]
    -n, --dry-run              Don't actually rename files. Just print
    -V, --version              Print version information

Current shortcomings

  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
  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.

You might also like...
Minimal Pandoc compiler - HTML

Minimal Pandoc compiler - HTML

82 fun and easy to use, lightweight, spinners for Rust, with minimal overhead.
82 fun and easy to use, lightweight, spinners for Rust, with minimal overhead.

Spinners for Rust 82 fun and easy to use, lightweight, spinners for Rust, with minimal overhead, all the way from simple dots, to fun emoji based "spi

Fast, minimal, feature-rich, extended formatting syntax for Rust!

Formatting Tools Fast, minimal, feature-rich, extended formatting syntax for Rust! Features include: Arbitrary expressions inside the formatting brace

Minimal and blazing-fast file server. For real, this time.

Zy Minimal and blazing-fast file server. For real, this time. Features Single Page Application support Partial responses (Range support) Cross-Origin

Minimal server (with maximal security) for turning off an X10-controlled fan over HTTP

"Fan Remote" A self-contained Rust binary to expose a single X10 command (turn off that fan) as an HTML form button. In its current form, it's highly

A minimal browser with a super simple rendering engine for HTML and CSS, using Rust.

minimal-browser A minimal browser with a super simple rendering engine for HTML and CSS, using Rust. Credit: https://github.com/mbrubeck and https://l

ChatGPT CLI - A minimal assistant in the terminal
ChatGPT CLI - A minimal assistant in the terminal

ChatGPT CLI A lightweight ChatGPT CLI - Chat completion. Interact with ChatGPT from your terminal and save the conversation in a text file. Get starte

Beautiful, minimal, opinionated CLI prompts inspired by the Clack NPM package
Beautiful, minimal, opinionated CLI prompts inspired by the Clack NPM package

Effortlessly build beautiful command-line apps with Rust 🦀 ✨ Beautiful, minimal, opinionated CLI prompts inspired by the @clack/prompts npm package.

Minimal, blazing fast Node.js script runner

nrr Minimal, blazing fast Node.js script runner. Why? nrr initializes and resolves scripts way faster than package managers. It achieves this by provi

Comments
  • Bump clap from 3.2.22 to 4.0.17

    Bump clap from 3.2.22 to 4.0.17

    Bumps clap from 3.2.22 to 4.0.17.

    Release notes

    Sourced from clap's releases.

    v4.0.17

    [4.0.17] - 2022-10-18

    Fixes

    • Allow using Arg::last(true) with Arg::value_hint(ValueHint::CommandWithArguments)

    v4.0.16

    [4.0.16] - 2022-10-18

    Fixes

    • Arg::exclusive(true) should not be exclusive with the argument's own ArgGroup

    v4.0.15

    [4.0.15] - 2022-10-13

    Fixes

    • (error) Don't suggest -- when it doesn't help
    • (error) Be more consistent in quoting, punctuation, and indentation in errors

    v4.0.14

    [4.0.14] - 2022-10-12

    Fixes

    • Only put ArgGroup in ArgMatches when explicitly specified, fixing derives handling of option-flattened fields (#4375)

    v4.0.13

    [4.0.13] - 2022-10-11

    Features

    • (derive) Allow () for fields to mean "don't read" (#4371)

    v4.0.12

    [4.0.12] - 2022-10-10

    Features

    • Added TypedValueParser::try_map for when adapting an existing TypedValueParser can fail
    • (error) Create errors like clap with Error::new, Error::with_cmd, and Error::insert

    v4.0.11

    [4.0.11] - 2022-10-09

    Fixes

    • (help) Fix wrapping calculations with ANSI escape codes

    ... (truncated)

    Changelog

    Sourced from clap's changelog.

    [4.0.17] - 2022-10-18

    Fixes

    • Allow using Arg::last(true) with Arg::value_hint(ValueHint::CommandWithArguments)

    [4.0.16] - 2022-10-18

    Fixes

    • Arg::exclusive(true) should not be exclusive with the argument's own ArgGroup

    [4.0.15] - 2022-10-13

    Fixes

    • (error) Don't suggest -- when it doesn't help
    • (error) Be more consistent in quoting, punctuation, and indentation in errors

    [4.0.14] - 2022-10-12

    Fixes

    • Only put ArgGroup in ArgMatches when explicitly specified, fixing derives handling of option-flattened fields (#4375)

    [4.0.13] - 2022-10-11

    Features

    • (derive) Allow () for fields to mean "don't read" (#4371)

    [4.0.12] - 2022-10-10

    Features

    • Added TypedValueParser::try_map for when adapting an existing TypedValueParser can fail
    • (error) Create errors like clap with Error::new, Error::with_cmd, and Error::insert

    [4.0.11] - 2022-10-09

    Fixes

    • (help) Fix wrapping calculations with ANSI escape codes

    [4.0.10] - 2022-10-05

    Features

    • (derive) Support #[arg(flatten)] on Option types (#4211, #4350)

    ... (truncated)

    Commits
    • b9dfbbf chore: Release
    • a6c8f6a docs: Update changelog
    • e11afa2 Merge pull request #4401 from epage/last
    • 1ead5ef fix(complete): Support last(true) with CommandWithArguments
    • e50a11a Merge pull request #4399 from j-browne/link-fix
    • a1d4476 Fix a broken link in ValueEnum docs
    • cbb05d5 chore: Release
    • b77bd0c docs: Update changelog
    • 466b6f8 Merge pull request #4397 from epage/exclusive
    • 45dcf0e fix(parser): Don't make Args exclusive with their ArgGroup
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 4
  • Bump clap from 3.2.21 to 3.2.23

    Bump clap from 3.2.21 to 3.2.23

    Bumps clap from 3.2.21 to 3.2.23.

    Release notes

    Sourced from clap's releases.

    v3.2.23

    [3.2.23] - 2022-10-24

    Fixes

    • Upgrade to textwrap 0.16

    v3.2.22

    [3.2.22] - 2022-09-16

    Fixes

    • Unify dependencies on terminal_size to the 0.2 release
    Changelog

    Sourced from clap's changelog.

    [3.2.23] - 2022-10-24

    Fixes

    • Upgrade to textwrap 0.16

    [3.2.22] - 2022-09-16

    Fixes

    • Unify dependencies on terminal_size to the 0.2 release
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
Owner
Stephan Sokolow
My pre-June 2022 commits don't show up in the activity view because GitHub's "claim your commits" form never anticipated user.email being a URL to avoid spam
Stephan Sokolow
Non-Recursive Inverting of Binary Tree in Rust

Non-Recursive Inverting of Binary Tree in Rust The idea is to implement the classical Inverting of Binary Tree but without using recursion. Quick Star

Tsoding 15 Dec 6, 2022
Recursive-OVOTE: OVOTE enjoying Plonky2 recursion

rovote: recursive ovote Recursive-OVOTE: OVOTE enjoying Plonky2 recursion. Note: this repo is an experiment, do not use in production. The inner & out

Aragon ZK Research 6 Apr 2, 2023
MinMon - an opinionated minimal monitoring and alarming tool

MinMon - an opinionated minimal monitoring and alarming tool (for Linux) This tool is just a single binary and a config file. No database, no GUI, no

Florian Wickert 177 Jan 5, 2023
a command-line tool that transforms a Git repository into a minimal format for ChatGPT queries

gprepo /dʒiːpiːˈɹi:pi:oʊ/ a command-line tool that transforms a Git repository into a minimal format for ChatGPT queries. Features Excludes LICENSE an

null 6 Apr 20, 2023
A minimal CLI framework written in Rust

seahorse A minimal CLI framework written in Rust Features Easy to use No dependencies Typed flags(Bool, String, Int, Float) Documentation Here Usage T

Keisuke Toyota 223 Dec 30, 2022
A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf.

xplr A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf. [Quickstart] [Features] [Plugins] [Documentation] [Upgrade Guide] [

Arijit Basu 2.6k Jan 1, 2023
⚡️ Lightning-fast and minimal calendar command line. Written in Rust 🦀

⚡️ Lightning-fast and minimal calendar command line. It's similar to cal. Written in Rust ??

Arthur Henrique 36 Jan 1, 2023
A minimal argument parser

Pieces An argument parser built with control in mind. Parsing The results you get are dependent on what order you parse in. If you want to say only pa

ibx34 3 Sep 30, 2021
☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell

☄??️ The minimal, blazing-fast, and infinitely customizable prompt for any shell

Starship Command 31.6k Dec 30, 2022
A minimal readline with multiline and async support

RustyLine Async A minimal readline with multiline and async support. Inspired by rustyline , async-readline & termion-async-input.

Zyansheep 16 Dec 15, 2022