Gifford47 / python_find_replace

a python script, that searches und replace strings with regex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python find and/or replace script

A python script, that searches und replaces whole(!) strings with regex. You can specify a path of operation or a single file. If nothing is choosen, the current working directory is used.

Please provide these arguments:
-r <search_string> <replace_string> = replace string in every file in current working directory.
-d <"{'old'':'new','old2':'new2'}"> = replace strings from in every file in current working or "PATH" directory.
-f <search_string> = Find string in files in current working directory.

Optional:
-p = Define Path or file for your action. If not spcified, the current working directory will be used.

Example:
find_replace.py -r old_string new_string -p "C:\choose\dir"

Output:
Working directory:C:\Users\bratzh\Documents\PyCharm\find_replace
searching...
File 'C:\Users\test\Documents\find_replace\new.txt' changed 2 times!
File 'C:\Users\test\Documents\find_replace\second.txt' changed 1 times!
Total files changed: 2

About

a python script, that searches und replace strings with regex


Languages

Language:Python 100.0%