This script replaces strings in requested files.
It expects 2 files with the same amount of lines to create the replacement "rules".
Each line from the first file will be replaced with the corresponding line from the second file.
Contents
This project requires:
- Python 3.6
In your working folder (your home folder, for example)
git clone https://github.com/yevgenykuz/string-replacer.git
- Create your replacement "rules" by editing the provided "before.txt" and "after.txt" files. You can point to your own files instead (see arguments)
- Put the files you want to scan in the provided "files" folder. You can point to your own folder instead (see arguments)
Run with:
python replace_strings_in_files.py
usage: replace_strings_in_files.py [-h] [-p PATH] [-e FILE_EXTENSION] [-b STRING_LIST_BEFORE] [-a STRING_LIST_AFTER] optional arguments: -h, --help show this help message and exit -p PATH The path to the directory that contains the files to scan (default is 'files') -e FILE_EXTENSION The extension of the files to scan for string replacement (scans everything by default) -b STRING_LIST_BEFORE The file that contains strings to convert (each string in its own line) -a STRING_LIST_AFTER The file that contains strings to convert to (each string in its corresponding line)