Python scripting to fix up redirectors in a folder?

Let me necro this because this is the top hit from Google search.
And this should help other people with similar problem.

This is how the folder context menu Fix Up Redirectors in Folder do it.
You will need to be able to access the UnrealEngine github to view the code.
Also this is the link from UE5.0.3
https://github.com/EpicGames/UnrealEngine/blob/d9d435c9c280b99a6c679b517adedd3f4b02cfd7/Engine/Plugins/Editor/ContentBrowser/ContentBrowserAssetDataSource/Source/ContentBrowserAssetDataSource/Private/AssetFolderContextMenu.cpp#L256-L257

Here the copied snapshot from the source code.

			// Transform Objects array to ObjectRedirectors array
			TArray<UObjectRedirector*> Redirectors;
			for (auto Object : Objects)
			{
				auto Redirector = CastChecked<UObjectRedirector>(Object);
				Redirectors.Add(Redirector);
			}

			// Load the asset tools module
			FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
			AssetToolsModule.Get().FixupReferencers(Redirectors);

We already have FAssetData::IsRedirector() but currently Python cannot access FAssetToolsModule. So, We still need to expose it through C++.

1 Like