repren
Rename files and replace text with patterns
TLDR
Rename with pattern
SYNOPSIS
repren [--rename] [--from pattern] [--to pattern] [options] files
DESCRIPTION
repren is a versatile batch tool for renaming files and performing search-and-replace operations across multiple files using regular expressions or literal patterns. It can apply several replacement rules simultaneously from a patterns file, making it efficient for large-scale refactoring tasks like renaming variables, updating imports, or reorganizing file structures.
A key feature is case-preserving replacement, which automatically maintains the capitalization style of the original text. For example, replacing "foo" with "bar" will also convert "Foo" to "Bar" and "FOO" to "BAR". The --dry-run flag shows all planned changes without modifying any files, allowing safe verification before committing to batch operations.
The tool supports both file content replacement and file/directory renaming with the --rename flag. Patterns can use full Python regular expressions with capture groups, or literal strings with --literal for straightforward substitutions.
PARAMETERS
--rename
Rename files/directories.--from PATTERN
Search pattern.--to PATTERN
Replacement pattern.--patterns FILE
Patterns from file.--dry-run
Preview only.--preserve-case
Match case style.--literal
Literal strings.-r, --recursive
Recursive operation.
CAVEATS
Python required. Complex patterns need care. Backup important files.
HISTORY
repren was created as a versatile renaming and replacement tool supporting complex batch operations with pattern files.
