From 67140ff8b3fb7ebe87873b41184494e8d0b73f0b Mon Sep 17 00:00:00 2001 From: Rogee Date: Fri, 31 Oct 2025 11:10:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20renamer=20CLI=20?= =?UTF-8?q?=E7=9A=84=E5=88=9D=E5=A7=8B=E6=96=87=E6=A1=A3=E5=92=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bcf0d9a --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# renamer + +`renamer` is a preview-first, undoable batch renaming CLI for local file systems. It wraps a traversal engine, scoped filters, and a newline-delimited `.renamer` ledger so you can trial changes safely before committing them. + +## Highlights + +- Preview every operation with conflict detection before touching the filesystem. +- Share a single set of scope flags (`--path`, `--recursive`, `--include-dirs`, etc.) across all commands. +- Apply literal replacements, substring removals, extension normalization, positional inserts, or regex-driven renames. +- Persist every batch into a `.renamer` ledger and undo the most recent change set at any time. +- Output results in table or plain text formats to fit automation and scripting workflows. + +## Installation + +Prerequisites: Go 1.24+ + +```bash +git clone https://github.com/rogeecn/renamer.git +cd renamer +go install ./... +``` + +The `renamer` binary will be placed in your `GOBIN` (defaults to `$GOPATH/bin`). + +## Usage + +The CLI follows the pattern: + +```bash +renamer [global scope flags] [command args] +``` + +### Shared scope flags + +All subcommands accept these persistent flags: + +- `--path `: Working directory (defaults to current directory). +- `-r, --recursive`: Traverse subdirectories. +- `-d, --include-dirs`: Include directories in results. +- `--hidden`: Include hidden files and directories. +- `-e, --extensions ".jpg|.png"`: Pipe-delimited list of extensions to target. +- `--dry-run`: Force preview-only mode. +- `--yes`: Confirm changes without prompting (mutating commands only). + +### Commands + +- `renamer list [--format table|plain] [--max-depth N]` — Preview the files and directories that match the active scope. +- `renamer replace ` — Replace multiple literal tokens in sequence. Shows duplicates and conflict warnings, then applies when `--yes` is present. +- `renamer remove ` — Strip ordered substrings from names with empty-name protection and duplicate detection. +- `renamer extension ` — Normalize heterogeneous extensions to a single target while keeping a ledger entry for undo. +- `renamer insert ` — Insert text at symbolic (`^`, `$`) or numeric offsets (positive or negative). +- `renamer regex