shenwei356 /brename
A practical cross-platform command-line tool for safely batch renaming files/directories via regular expression
★ 301⑂ 23👁 3⑃ 9● 33▤ 25
+1
Daily
+1
Weekly
301
stars
23
forks
3
watchers
9
prs
33
issues
25
releases
README
brename: batch renaming safely
brename is a cross-platform command-line tool for safely batch renaming files/directories via regular expressions.
Table of Contents
- Features
- Installation
- Usage
- Examples
- Real-world examples
- FAQS
- Contact
- License
- Starchart
Features
- Cross-platform. Supports Windows, Mac OS X and Linux.
- Windows file systems, including NTFS and FAT, are case-insensitive.
Some operations are allowed on Linux, while they could be dangerous on Windows.
For example, renaming test.tar.gz to test.tar will overwrite TEST.tar.
brename (v2.13.0 and later versions) can handle these cases appropriately (-w and -W).
- Safe. It helps you check for potential conflicts and errors before it's too late.
Some common conflicts and errors that might happen with commands like mv or rename:
- New path existed: Existing files might be overwritten, causing data loss.
- Overwriting newly renamed path. Existing files might be overwritten, causing data loss.
This case is hard to check by eye.
- Missing target: The new filename is empty, which is not allowed.
- New path ending with a space: Not allowed in Windows. It's legal in Linux, but might cause unexpected errors.
- New path ending with a period: Not allowed in Windows.
- Supporting dry runs. A good habit.
- Supporting Undo for the last rename operation, including completed moves from a failed run.
- Overwrites can be detected and users can choose whether to overwrite or skip them (-o/--overwrite-mode).
- File filtering.
- Supports including (-f/--include-filters) and excluding (-F/--exclude-filters) files via regular expressions.
- No need to run commands like find ./ -name ".html" -exec CMD.
- Renaming submatches with corresponding values via a key-value file (-r "{kv}" -k kv.tsv).
- Renaming via ascending integers (-r "{nr}").
- Automatically making directories: e.g., renaming a-b-c.txt to a/b/c.txt.
- Recursively renaming both files and directories (-R/--recursive, -D/--including-dir, --only-dir).
Installation
brename is implemented in the Go programming language;
executable binary files for most popular operating systems are freely available
on the releases page.
Method 0: Conda
Install conda, then run
conda install -c conda-forge brename
Or use mamba, which is faster.
mamba install -c conda-forge brename
Method 1: Download binaries
brename v2.15.0
Tip: run brename -V to check for updates!
Version checks wait up to 30 seconds for GitHub and report network or HTTP errors.
A release that differs from the installed version is shown as the latest release;
it may be older than a local development build.
OS |Arch |File |Download Count
:------|:---------|:------------------------------------------------------------------------------------Top issues
#30fatal error: runtime: out of memory9 comments · 2023-09-22#14Issue when working on external drive8 comments · 2020-03-02#27no match on UTF-8 chars5 comments · 2022-12-31
Latest release
brename v2.15.0 v2.15.0 2026-10-30- v2.15.0
- flag -N/--nature-sort now applies to renaming as well as listing. 36
- fix: correct exclude-filter assignment and recursive filtering, handle explicit search paths and --only-dir consistently, and inspect metadata without reading file contents. Exclude-filter assignment fix by @mazkev. 41
- fix: validate normalized target names and conflicts, preserve symlink and .. resolution, distinguish hard links, reject moving directories into their own descendants, and protect the working directory, its ancestors, dangling symlinks, and undo log paths during execution and renam