Fast recursive search-and-replace across file contents and file/folder names in a directory. Built in Rust with parallel content rewriting.
cargo build --release # binary at target/release/dsrdsr <PATTERN> <REPLACEMENT> [PATH] [-p <SEARCH> <REPLACE>]... [OPTIONS]PATH defaults to the current directory. The positional PATTERN / REPLACEMENT
pair may be omitted if you supply at least one -p / --pair, in which case a
lone positional is taken as PATH.
| Flag | Description |
|---|---|
-p, --pair <SEARCH> <REPLACE> |
Add another search/replacement pair (repeatable). Pairs apply in order, each over the previous result, and share --regex / --ignore-case. |
-e, --regex |
Treat PATTERN as a regular expression ($1/${name} expand in the replacement). |
-i, --ignore-case |
Case-insensitive matching. |
-n, --dry-run |
Show what would change without writing anything. |
--names-only |
Only rename files/folders, leave contents alone. |
--contents-only |
Only edit contents, leave names alone. |
-a, --hidden |
Include dotfiles/dot-directories. |
--no-ignore |
Don't respect .gitignore / .ignore. |
--git |
Git mode: require a repo, never touch .git, refuse to modify git-ignored paths (enforced even with --hidden). |
--follow |
Follow symlinks. |
-v, --verbose |
Print every change, not just the summary. |
-s, --suggest |
After the summary, report counts of case/separator variants of the search pattern(s) (e.g. DevenvTools, DEVENV_TOOLS) found in contents and names. Variants already covered by a specified pair are omitted. In case-sensitive runs it also lists the actual case-only spellings of each needle that occur (e.g. DevEnvTools). |
# Preview a literal rename of "foo" -> "bar" everywhere
dsr foo bar ./src --dry-run --verbose
# Case-insensitive, apply for real
dsr foo bar ./src -i
# Regex with a capture group
dsr -e 'version=(\d+)' 'v$1' ./config
# Dry run that also flags other casings of the needle you may want to handle
dsr devenv-tools toolkit ./src --dry-run --suggest
# Several casings at once: rename every variant in a single pass
dsr devenv-tools toolkit -p DevenvTools Toolkit -p DEVENV_TOOLS TOOLKIT ./src- Contents are rewritten in parallel; renames run afterwards, deepest-path-first, so renaming a parent folder never invalidates a child path.
- Binary files (NUL byte in the first 8 KB) are skipped for content edits.
- By default
.gitignored and hidden paths are skipped (-a/--no-ignoreto include). - A rename that would overwrite an existing path is reported as an error and skipped.
- Exit code is non-zero on fatal errors; per-path errors are collected and printed at the end.