/Engine/Plugins/Editor/EditorScriptingUtilities/Source/EditorScriptingUtilities/Public/EditorLevelLibrary.h
Find the references of the material MaterialToReplaced on all the MeshComponents provided and replace it by NewMaterial.
[UFUNCTION](Programming/UnrealArchitecture/Reference/Functions)(BlueprintCallable, Category="Editor Scripting | Dataprep", Meta=(DeprecatedFunction, DeprecationMessage="The Editor Scripting Utilities Plugin is deprecated - Use the function in Static Mesh Editor Subsystem")) static void ReplaceMeshComponentsMaterials ( const [TArray](API\Runtime\Core\Containers\TArray)< class [UMeshComponent](API\Runtime\Engine\Components\UMeshComponent) * > & MeshComponents, class [UMaterialInterface](API\Runtime\Engine\Materials\UMaterialInterface) * MaterialToBeReplaced, class [UMaterialInterface](API\Runtime\Engine\Materials\UMaterialInterface) * NewMaterial )