Skip to content

huajielong/QuickCodeReplace

Repository files navigation

v1.0 MIT Python 3.6+ Stars Cross-platform Multi-threading

⚡ QuickCodeReplace

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

中文说明


🤔 Still manually refactoring your codebase?

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

🚀 Quick Start

Requirements

Dependency Version
Python 3.6+

Pure Python scripts, no third-party dependencies required.

git clone https://github.com/huajielong/QuickCodeReplace.git
cd QuickCodeReplace

⚡ Core Features

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

📖 Usage Examples

File Content Replacement

python words_replacer.py /path/to/code --config_file replace_rules.txt

Configuration file replace_rules.txt:

old_project new_project
OldProject NewProject

File & Directory Renaming

Configure rules in rename_old2new.py:

REPLACEMENT_RULES = {
    'Hello world': 'hello everyone',
    'Cat': 'Dog'
}

Then run:

python rename_old2new.py /path/to/code

Full Workflow (Recommended)

# 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/code

❓ FAQ

What 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.

🤝 Contributing

Issues and Pull Requests are welcome!

Contributions Welcome

📄 License

MIT © huajielong


About

⚡ 大规模代码库快速批量替换工具 — 文件内容替换/文件名重命名/目录重命名,多线程加速,智能编码检测

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages