Skip to content

Tag: cargo

flatten a directory structure 🥾

I often find myself in a situation where I need to flatten a directory structure. I kept reusing variants of this script to flatten a directory using find.

I rewrote that with a little cli written in Rust:

It features:

  • 10~30x faster because eliminates subprocess launching and redundant directory scans.
  • Rust native filesystem API handling already takes care of spaces, Unicode, and symbols out-of-the-box. This was the a major breaking point of the original script and its variants.
  • Safeguards against conflicts and collisions.
  • Suits of tests coverages to avoid regressions.
  • –undo, –dryrun and other special subcommands.