No idea about importing to unreal with python. Just did not combined python and unreal yet.
This is next chatGPT reply:
import unreal
def import_textures(source_directory, destination_path):
# Create AssetImportTask
task = unreal.AssetImportTask()
task.automated = True
task.destination_path = destination_path
task.replace_existing = True
task.filename = source_directory
task.save = True
# Configure Texture Factory Settings
texture_factory = unreal.TextureFactory()
texture_factory.automated_import_should_detect_type = False # Prevent Unreal from detecting normal maps
texture_factory.compression_settings = unreal.TextureCompressionSettings.TC_DEFAULT # Set default compression
texture_factory.srgb = True # Ensure sRGB is enabled
task.factory = texture_factory # Assign factory to the import task
# Import the assets
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
print(f"Imported textures from {source_directory} to {destination_path}")
# Example Usage
import_textures("C:/TexturesToImport", "/Game/ImportedTextures")
and this is YOUR code modified by rubber duck:
import unreal
import glob
import shutil
def import_images():
all_files = glob.glob("D:/Trail/renderRS/*")
j = 0
for cur in all_files:
# Copy the current image to a temporary file
shutil.copy2(cur, 'D:/CometTMP.png')
# Create an import task
task = unreal.AssetImportTask()
task.filename = 'D:/CometTMP.png'
task.destination_path = '/Game/HoudiniRing/framesImages/'
task.destination_name = f'Comet.{str(j).zfill(4)}'
task.automated = True
task.save = True
task.replace_existing = True
# Configure TextureFactory settings
texture_factory = unreal.TextureFactory()
texture_factory.automated_import_should_detect_type = False # Prevent auto-detecting as normal map
texture_factory.compression_settings = unreal.TextureCompressionSettings.TC_DEFAULT # Force default compression
texture_factory.srgb = True # Ensure sRGB is enabled
# Assign the factory to the task
task.factory = texture_factory
# Execute the import
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
j += 1 # Increment counter
print(f"Imported {j} images successfully.")
# Run the import function
import_images()
ps.
I wonder if it works.