Open for Voting
Changing all bitmap resources path at once . ChatGPT suggestion.
Chat GPT wrote me a pyton script that should replace all bitmap resources to other folder .
here it is:
import xml.etree.ElementTree as ET import os def replace_bitmap_paths(sbs_file_path, old_path, new_path): # Parse the XML file tree = ET.parse(sbs_file_path) root = tree.getroot() # Find all elements with the 'bitmap' tag for bitmap_element in root.iter('bitmap'): # Get the current bitmap path current_path = bitmap_element.text # Check if the current path contains the old path if old_path in current_path: # Replace the old path with the new path new_bitmap_path = os.path.relpath(current_path, old_path) bitmap_element.text = os.path.join(new_path, new_bitmap_path) # Save the modified XML back to the file tree.write(sbs_file_path) # Example usage: sbs_file_path = 'path/to/your/file.sbs' old_path = 'textures/' new_path = 'new/path/to/bitmaps/' replace_bitmap_paths(sbs_file_path, old_path, new_path)
But it does nothing when I replace the path to actiual one in the end of the script . The paths stay same in my sbs .
Could sombody inspect the script and tell whats wrong please.
