- Apr 23, 2018
- 367
- 1,535
Here is the
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:
Escape special characters
Edit 1: small fixes and case sensitive by default. Use
Edit 2: File mask support instead of extensions and bugfixes and Python 3.11 support.
You must be registered to see the links
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
&
|
(
<
>
^
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: