toolkit / utils /remove_grandfathered.py
k4d3's picture
new remove_grandfathered
5ce54ff
raw
history blame contribute delete
819 Bytes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def remove_text_from_file(file_path, text_to_remove):
with open(file_path, 'r') as file:
content = file.read()
content = content.replace(text_to_remove, "")
with open(file_path, 'w') as file:
file.write(content)
def remove_text_from_files(root_dir, text_to_remove):
for subdir, _, files in os.walk(root_dir):
for file in files:
if file.endswith('.txt') or file.endswith('.tags'):
file_path = os.path.join(subdir, file)
remove_text_from_file(file_path, text_to_remove)
if __name__ == "__main__":
root_directory = '.' # Change this to your root directory
text_to_remove = "grandfathered content, "
remove_text_from_files(root_directory, text_to_remove)