Tool Python script for replacing text in many files at once

Surgy

Member
Modder
Apr 23, 2018
340
1,317
Here is the script I use when need to replace text in multiple files by file mask at once.
It accepts Regular Expressions from command line and multiple replacers from DSV-format table file replace.csv (using .csv extension for Office compatibility).

It's good idea to backup target files beforehand because it will change them in-place.

Usage:
Code:
replacers.py -e cp932 -p "*_log.txt,*.tmp" -d .\outdir -o "te(st)[^^\\w]+\\"\\d{2,}\\"" -n "te\\\\1 "
replacers.py -r
Escape special characters & | ( < > ^ with ^ and character " with \ inside patterns in command line for them to work properly.

Edit 1: small fixes and case sensitive by default. Use -i parameter for case insensitive operations.
Edit 2: File mask support instead of extensions and bugfixes and Python 3.11 support.
 
Last edited:

ouda

Member
Apr 30, 2018
159
54
can you do a tuto i am a nob i tried to remplace the name of the mc of
Meteor World Actor but it don't work