# Python scripting to fix up redirectors in a folder?

**URL:** <https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [April 22, 2019, 11:17pm UTC](https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267 "2019-04-22T23:17:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kakyoism](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kakyoism](https://forums.unrealengine.com/u/kakyoism)\
**Post date:** [April 22, 2019, 11:17pm UTC](https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267/1 "2019-04-22T23:17:11Z")

</div>

Other than the project-wise redirector fixing, i.e.:

```auto

UE4Editor.exe <GameName or uproject> -run=ResavePackages -fixupredirects -autocheckout -projectonly -unattended

```

could we fix up redirectors in a specified folder through scripting as we do with the context menu in the Content Browser?

I briefly looked at the high-level API in EditorAssetLibrary, other than

```auto

consolidate_assets(*asset_to_consolidate_to*, *assets_to_consolidate*) → bool

```

which does some obscure things:

Consolidates an asset by replacing all references/uses of the provided AssetsToConsolidate with references to AssetToConsolidateTo. This is useful when you want all references of assets to be replaced by a single asset. The function first attempts to directly replace all relevant references located within objects that are already loaded and in memory. Next, it deletes the AssetsToConsolidate, \*\*leaving behind object redirectors to AssetToConsolidateTo. \*\*The AssetsToConsolidate are DELETED by this function.: Modified objects will be saved if the operation succeeds.

I couldn’t find a straightforward API that mentions Redirectors. I expect something that would look like

```auto

fix_up_redirector(folder_path)

```

, but there is none, which is weird, considering that’s what you do exactly in the Editor.

---

<div class="post-metadata">

**Author:** ![MaxAuer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MaxAuer](https://forums.unrealengine.com/u/MaxAuer)\
**Post date:** [March 16, 2020, 9:19am UTC](https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267/2 "2020-03-16T09:19:24Z")

</div>

Just stumbled upon your question because I currently try to do something similar. I develop a plugin where a “fixup redirectors” step would be included in a workflow.

Did you ever find out how to do this from c++?

---

<div class="post-metadata">

**Author:** ![schiho](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@schiho](https://forums.unrealengine.com/u/schiho)\
**Post date:** [June 5, 2020, 6:47am UTC](https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267/3 "2020-06-05T06:47:32Z")

</div>

+1 That would be very beneficial!

@it is a little overkill having to that through a plugin

---

<div class="post-metadata">

**Author:** ![BoBoMX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BoBoMX](https://forums.unrealengine.com/u/BoBoMX)\
**Post date:** [October 4, 2022, 4:55am UTC](https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267/4 "2022-10-04T04:55:50Z")

</div>

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](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.

```auto
			// 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++.

---

<div class="post-metadata">

**Author:** ![zapan669](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zapan669](https://forums.unrealengine.com/u/zapan669)\
**Post date:** [June 26, 2024, 10:34pm UTC](https://forums.unrealengine.com/t/python-scripting-to-fix-up-redirectors-in-a-folder/125267/5 "2024-06-26T22:34:23Z")

</div>

consolidate\_assets() sounds like very similar to fix\_up\_redirectors (FixUpReferencers in C++)
