Convert .fbx files to .anim batch

Hello, I want to convert hundreds of external .fbx fies to .anim files via script to use in Unity. But I couldn’t figured out how to, thanks for your help.

using UnityEngine;
using UnityEditor;

public class test : MonoBehaviour {

	new AnimationClip[] animation;

	void Start(){

		animation = Resources.LoadAll<AnimationClip> ("Model");
		foreach (AnimationClip i in animation) {
			Debug.Log ("Animation: " +;
			AssetDatabase.CreateAsset(i, string.Format("Assets/AnimationClips/{0}.anim",;