$0+

Text Replacement Python Script

I want this!

Text Replacement Python Script

$0+

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:

  1. 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 the source directory.
  2. Running the Script:
    • Open your terminal or command prompt.
    • Navigate to the directory containing the script.
    • Run the script using the following command:
      python replace.py "old_text" "new_text"
      Replace old_text with the text you want to search for and replace, and new_text with the text you want to use as a replacement.
  3. 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.
$
I want this!
Size
1.98 KB
Copy product URL