Blender

Blender

Not enough ratings
Renaming textures and UDIMs (EN)
By ※RED※SKULL※
Marmoset doesn't work with UDIM, so I had to rename the maps to Substance myself. To automate this process, I created the following code using Chat GPT.
   
Award
Favorite
Favorited
Unfavorite
Purpose/application
Marmoset doesn't work with UDIM, so I had to rename the maps to Substance myself. To automate this process, I created the following code using Chat GPT.
Rename texture
import os def rename_textures(folder_path, new_prefix): if not os.path.exists(folder_path): print(f"Folder path {folder_path} does not exist.") return files_found = False for filename in os.listdir(folder_path): print(f"Checking file: {filename}") if filename.endswith((".png", ".jpg", ".tga", ".psd")): files_found = True parts = filename.split('_') if len(parts) >= 2: # Get the file extension name_parts = filename.split('.') extension = name_parts[-1] base_name = '_'.join(name_parts[:-1]) base_parts = base_name.split('_') # Form the new file name with the new prefix and preserved map type new_name = f"{new_prefix}_{base_parts[-1]}.{extension}" old_file = os.path.join(folder_path, filename) new_file = os.path.join(folder_path, new_name) if not os.path.exists(new_file): # Check if the file already exists os.rename(old_file, new_file) print(f"Renamed {filename} to {new_name}") else: print(f"Skipped {filename}, target name {new_name} already exists") if not files_found: print("No matching files found in the folder.") # Function call folder_path = r"PATH TO TEXTURES" # "PATH TO TEXTURES" Path to your textures. Example: "D:\POLYGONS\BLENDER" new_prefix = "NAME" # "NAME" Name for you
Rename texture for UDIM
import os def rename_textures(folder_path, new_prefix): if not os.path.exists(folder_path): print(f"Folder path {folder_path} does not exist.") return files_found = False for filename in os.listdir(folder_path): print(f"Checking file: {filename}") if filename.endswith((".png", ".jpg", ".tga", ".psd")): files_found = True parts = filename.split('_') if len(parts) >= 2: # Get the file extension name_parts = filename.split('.') extension = name_parts[-1] base_name = '_'.join(name_parts[:-1]) base_parts = base_name.split('_') # Form the new file name with the new prefix and preserved map type new_name = f"{new_prefix}_{base_parts[-1]}.1001.{extension}" old_file = os.path.join(folder_path, filename) new_file = os.path.join(folder_path, new_name) if not os.path.exists(new_file): # Check if the file already exists os.rename(old_file, new_file) print(f"Renamed {filename} to {new_name}") else: print(f"Skipped {filename}, target name {new_name} already exists") if not files_found: print("No matching files found in the folder.") # Function call folder_path = r"PATH TO TEXTURES" # "PATH TO TEXTURES" Path to your textures. Example: "D:\POLYGONS\BLENDER" new_prefix = "NAME" # "NAME" Name for your textures that precedes the texture type. Example: "OLDM1911_ao" rename_textures(folder_path, new_prefix)

In the string: new_name = f"{new_prefix}_{base_parts[-1]}.1001.{extension}"

1001 indicates the UDIM number of the tile, if you need a different tile, follow this picture

Bugs
If the file already has a UDIM value and the value is changed from 1001 to 1002, then when using the code, the texture name (ao, normal) will be replaced by the tile number and the name will be of the type "NAME_1001.1002.psd"

Therefore, it is still suitable for renaming maps from Marmoset for Substance, but not suitable for renaming ready-made maps of the type "NAME_ao.1001.psd"