Fast batch find-and-replace tool for large-scale codebases — file content replacement, file renaming, directory renaming, multi-threaded acceleration, and intelligent encoding detection.
📝 Content Replace · 📁 File Rename · ⚡ Multi-threading · 🧠 Encoding Detection
🚀 Quick Start • ⚡ Core Features • 📖 Usage Examples • ❓ FAQ
Project renames, codebase migrations, brand rebranding — each one involves mass content replacement and file renaming:
| Pain Points | QuickCodeReplace Solution |
|---|---|
| ❓ Thousands of files to replace strings manually | ✅ Batch Replace — one config, whole codebase |
| ❓ File and directory names need changing too | ✅ Smart Rename — sync files/dirs in one go |
| ❓ Mixed GBK/UTF-8 encodings causing garbled text | ✅ Auto Encoding Detection — detect encoding automatically |
| ❓ Accidentally corrupting binary files | ✅ Safe Protection — auto-skip binary files |
| ❓ Slow replacement, waiting forever | ✅ Multi-threaded — parallel processing |
| Dependency | Version |
|---|---|
| Python | 3.6+ |
Pure Python scripts, no third-party dependencies required.
git clone https://github.com/huajielong/QuickCodeReplace.git
cd QuickCodeReplace| Feature | File | Description |
|---|---|---|
| 📝 Content Replacement | words_replacer.py |
Batch replace strings in code files |
| 📁 File Renaming | rename_old2new.py |
Rename files based on replacement rules |
| 📂 Directory Renaming | rename_old2new.py |
Rename directories based on replacement rules |
| ⚡ Multi-threaded Processing | Built-in | Improve processing speed |
| 🧠 Intelligent Encoding Detection | Built-in | Auto-detect file encoding |
| 🚫 Binary File Skipping | Built-in | Process text files only |
| 📋 Config File Support | Built-in | Read replacement rules from config file |
python words_replacer.py /path/to/code --config_file replace_rules.txtConfiguration file replace_rules.txt:
old_project new_project
OldProject NewProject
Configure rules in rename_old2new.py:
REPLACEMENT_RULES = {
'Hello world': 'hello everyone',
'Cat': 'Dog'
}Then run:
python rename_old2new.py /path/to/code# 1. Replace file content first
python words_replacer.py /path/to/code --config_file rules.txt
# 2. Then rename files and directories
python rename_old2new.py /path/to/codeWhat file encodings are supported?
The tool automatically detects file encoding, supporting UTF-8, GBK, GB2312, Big5, and other common encodings. For files with special encodings, we recommend converting them first.Will it corrupt binary files?
No. The tool automatically skips the .git directory and binary files, processing only text files.Are the replacement rules case-sensitive?
Yes. You need to set separate rules for different casing, e.g., "old_project" and "OldProject" must be configured separately.Do I need a backup before replacing?
A backup is recommended. While the tool skips dangerous files, it's best practice to back up your data before large-scale operations.Issues and Pull Requests are welcome!
MIT © huajielong