I want to create a script to create a number of retargeted animations from one folder to a different folder. I am following the instructions on this web page, but the script provided doesn’t allow you to set the target folder
LogPython: Error: batch_op = unreal.IKRetargetBatchOperation.duplicate_and_retarget(
LogPython: Error: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LogPython: Error: TypeError: duplicate_and_retarget() ‘target_path’ is an invalid keyword argument for this function
target_path is not an argument on the duplicate_and_retarget binding in the editor you are running. The 5.8 experimental docs show a newer signature than the one Python actually exposed, which is why you get “invalid keyword argument”. The static method takes the asset list, source mesh, target mesh, retargeter, then search / replace / prefix / suffix / include referenced assets. It duplicates next to the source (or with your prefix/suffix). It does not take a destination folder.
Retarget with a suffix so the new assets do not collide, then move them:
import unreal
asset_subsystem = unreal.get_editor_subsystem(unreal.EditorAssetSubsystem)
asset_lib = unreal.EditorAssetLibrary
source_paths = [
"/Game/Characters/Mannequins/Animations/Manny/MM_Fall_Loop",
"/Game/Characters/Mannequins/Animations/Manny/MM_Idle",
]
assets_to_retarget = [asset_subsystem.find_asset_data(p) for p in source_paths]
retargeter = unreal.load_asset("/Game/Characters/Mannequins/Rigs/RTG_Mannequin")
new_assets = unreal.IKRetargetBatchOperation.duplicate_and_retarget(
assets_to_retarget,
None, # source mesh: use the mesh on the IK Retargeter
None, # target mesh: same
retargeter,
"", "", "",
"_Retarget",
True,
)
dest = "/Game/Characters/Mannequins/Animations/Retargeted"
if not asset_lib.does_directory_exist(dest):
asset_lib.make_directory(dest)
for data in new_assets:
src = str(data.package_name)
name = str(data.asset_name)
asset_lib.rename_asset(src, f"{dest}/{name}")
None for the two meshes is correct when the IK Retargeter already has a source and target IK Rig. Passing a mesh only overrides that. If new_assets comes back empty, find_asset_data usually returned an invalid FAssetData (path typo) or the retargeter has no target IK Rig.
To see the signature your build actually has, run help(unreal.IKRetargetBatchOperation.duplicate_and_retarget) in the Output Log. If a later hotfix adds a context struct with a target directory, that help text will show it. Until then, suffix plus rename_asset is the supported way to land the clips in another folder.