Python - Residual Redirectors in headless mode.

Hello,

We are trying to rename few assets but in doing so it leaves redirectors of old assets behind,

we are trying to fix that using this function

Plain Text

AssetToolsModule.Get().FixupReferencers(Redirectors,false,ERedirectFixupMode::DeleteFixedUpRedirectors);

but this function opens up a dialog box before we can fix redirectors, we are running this whole process using python using -silent and -unattended.

Is there a way rename and fix redirectors at the same time or maybe select the correct option from redirector dialog box window using code, without manual intervention.

We have also tried using this -fixupredirects by launching the same project with this command but in this case it also doesn’t work because we want to fix redirectors while unreal is still running.

Hi Elliott,

I took a look at this, and from what I can tell, there isn’t a headless way to do this in Python. However, to sanitize the project, you could call this from Python in your validation and check-in portion of your workflow. The ResavePackages commandlet has a -fixupredirects flag that works pretty well for this.

https://dev.epicgames.com/documentation/en-us/unreal-engine/asset-redirectors-in-unreal-engine?application_version=5.6#cleanupredirectorsusingtheresavepackagescommandlet

Here is my quick batch script I used for testing. Replace my paths with yours. I use pause in the end of the .bat script so I can see the output, it’s optional.

Set "UECMDExePath=D:\UE\UE_5.6\Engine\Binaries\Win64\UnrealEditor-Cmd.exe" Set "Uproject=D:\P4V\PE\Sandbox\Mike.Weiss\UDN_PyRedirect\UDN_PyRedirect.uproject" call %UECMDExePath% %Uproject% -run=ResavePackages -fixupredirects -autocheckout -projectonly -unattended pauseEdit: I like this approach as it also will check out stuff from version control for us.

I hope this helps.

- Mike

Hey Mike,

Thanks for your response, we’ll see how this can work for us :slight_smile:

That sounds like a plan. I’ll close this for now, and if you have an update, feel free to update this thread. Then we can take it from there!

Best wishes,

Mike