Rename AnimationClip through script?

So I got lots of fbx format animation files, each animation file contain only one AnimationClip, and all AnimationClip named Take 001 by default.
Obvisouly, those AnimationClip’s name need to be modified, in this case, I want to modify its name to filename.
So I was wonder how could I do this through script?
I try something like this, of course it won’t work

AnimationClip ac = (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/Animation/Thug/Step/Step_Back_Long.FBX", typeof(AnimationClip));
ac.name = "Step_Back_Long";

I haven’t done this, but try defining ac as an Asset instead of an AnimationClip, then modify the Asset.name. The description for Asset.name in the API doesn’t say it’s read-only, but it does says it’s for “get”-ing the name… worth a try.

This?

UnityEditor.VersionControl.Asset ac = UnityEditor.VersionControl.Provider.GetAssetByPath("Assets/Animation/Thug/Step/Step_Back_Long.FBX");
ac.name = "Step_Back_Long";

Yes, name is read only.

I got some progress here

ModelImporter modelImport = AssetImporter.GetAtPath("Assets/Animation/Thug/Takedown/Takedown_Fast_02.FBX") as ModelImporter;
ModelImporterClipAnimation[] clipAnimations = modelImport.defaultClipAnimations;
for (int i = 0; i < clipAnimations.Length; i++)
{
    clipAnimations[i].name = "Takedown_Fast_02";
}
modelImport.clipAnimations = clipAnimations;
modelImport.SaveAndReimport();

It can modify AnimationClip’s name, but after that, tons of error message occurrs.


I honestly don’t know why since I am a newbie?
Anybody got a idea?