import os dirs = [r'assets/css/vendor', r'assets/css/sections', r'assets/css/widgets'] replacements = [ ('../fonts/', '../../fonts/'), ('assets/images/', '../../images/'), ('assets/fonts/', '../../fonts/') ] for d in dirs: if not os.path.exists(d): print(f"Directory {d} does not exist") continue for root, _, files in os.walk(d): for f in files: if f.endswith('.css'): path = os.path.join(root, f) try: with open(path, 'r', encoding='utf-8', errors='ignore') as file: content = file.read() new_content = content for old, new in replacements: new_content = new_content.replace(old, new) if new_content != content: with open(path, 'w', encoding='utf-8') as file: file.write(new_content) print(f"Updated {path}") except Exception as e: print(f"Error processing {path}: {e}")