#rename #recursion #directory #snake-case #hidden #folder #verbose

app snakit

Command-line tool that recursively renames all files and folders within a specified directory to snake_case

2 releases

new 0.1.1 Feb 2, 2025
0.1.0 Feb 2, 2025

#201 in Filesystem

Download history 108/week @ 2025-01-28

108 downloads per month

MIT license

10KB
123 lines

snakit

snakit is a command-line tool written in Rust that recursively renames all files and directories in a given directory to snake_case.

Features

  • Recursive Renaming: Process files and subdirectories recursively.
  • Dry-Run Mode: Preview changes without modifying your filesystem.
  • Hidden File Support: Optionally include or skip hidden files and directories.
  • Verbose Output: See detailed logs of the renaming process.
  • Collision Handling: If a renamed file or folder already exists, a numeric suffix is added to ensure uniqueness.

Installation

cargo install snakit

Usage

You can execute snakit using the following syntax:

snakit <path> [OPTIONS]

Command-Line Arguments

  • <path>
    The path to the directory in which files and folders will be renamed.

Options

  • -d, --dry-run
    Enable dry run mode. Displays the changes that would be made without applying them.

  • --include-hidden
    Include hidden files and directories in the renaming process.
    (By default, hidden files and directories are skipped.)

  • -v, --verbose
    Enable verbose mode to show detailed renaming information for each file and folder processed.

Example

Perform a dry-run on a directory:

snakit ./my_directory --dry-run --verbose

Rename all files and folders in a directory:

snakit ./my_directory --verbose

How It Works

snakit reads the specified directory and processes each file and folder:

  1. It checks if the file or folder should be processed (skips symlinks and – by default – hidden files).
  2. It converts the file or folder name to snake_case using the heck crate.
  3. If the snake_case name is different from the original, it renames the file or folder.
  4. If a name collision occurs, it automatically appends a numeric suffix to generate a unique name.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • clap for command-line argument parsing.
  • anyhow for error handling.
  • heck for case conversion.

Dependencies

~1.2–1.8MB
~33K SLoC