Go to file
2023-11-17 13:41:44 +01:00
LICENSE Initial commit 2023-08-22 22:21:44 +02:00
README.md Implemented multiple paths 2023-11-17 12:06:33 +01:00
replace_string.py solved verbose bugs 2023-11-17 13:41:44 +01:00

Bulk String Replacer

bulk-string-replacer is a Python-based command-line utility that allows for comprehensive search and replacement operations within file and folder names, as well as within file contents across specified directories. It's designed to handle bulk updates quickly and efficiently, with support for recursive directory traversal, hidden files, and a preview mode to review changes before they're applied.

Author

Kevin Veen-Birkenbach

Background

Learn more about the development and use cases of this tool in the original conversation with the developer.

Getting Started

Prerequisites

  • Python 3.x
  • Access to a command-line interface

Installation

Clone the repository to your local machine:

git clone https://github.com/kevinveenbirkenbach/bulk-string-replacer.git

Change into the project directory:

cd bulk-string-replacer

Usage

Run the script with Python, specifying your target paths, the string to be replaced, and the new string:

python replace_string.py old_string --new-string new_string_value --options paths...

Options

  • old_string: The string you want to search for and replace.
  • --new-string: The string that will replace old_string. Defaults to an empty string if not specified.
  • --recursive: Recursively process all subdirectories and files within the given paths.
  • --folder: Replace string occurrences within folder names.
  • --files: Replace string occurrences within file names.
  • --content: Replace string occurrences within the contents of the files.
  • --preview: Preview changes without applying them. No files will be modified.
  • --verbose: Output detailed information during the execution of the script.
  • --hidden: Include hidden files and directories in the operation.

Paths are specified at the end of the command, separated by spaces. For example:

python replace_string.py "search_string" --new-string "replacement_string" --recursive --verbose /path/to/first/directory /path/to/second/directory

Replace /path/to/first/directory and /path/to/second/directory with the actual paths you want to process.

Contributions

Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.

License

This project is open-sourced under the GNU Affero General Public License v3.0. See the LICENSE file for more details.