Text Replacement Python Script
$0+
$0+
https://schema.org/InStock
usd
LearnGPT.today
Description:
This script performs a bulk text replacement in files located in a specified source directory. It supports files with the extensions .txt
, .csv
, .html
, .htm
, and .php
. The modified files are then saved to a separate result directory with the same filenames.
Requirements:
- Python 3.x
-
chardet
library (To install:pip install chardet
)
Instructions:
-
Setup:
- Ensure you have Python installed and the
chardet
library. - Place the script in a directory of your choice.
- Create a directory named
source
in the same location as the script. Place all the files you want to modify inside thesource
directory.
- Ensure you have Python installed and the
-
Running the Script:
- Open your terminal or command prompt.
- Navigate to the directory containing the script.
- Run the script using the following command:
Replacepython replace.py "old_text" "new_text"
old_text
with the text you want to search for and replace, andnew_text
with the text you want to use as a replacement.
-
Results:
- After the script completes, check the
result
directory (which will be created if it doesn't exist). This directory will contain all the modified files.
- After the script completes, check the
Size
1.98 KB
Add to wishlist