Loading animation clips in code

Hey all,

Can someone tell me how to get AnimationClips from a model in code, so I can add them to the Animation component in code.
I know how to do it in the inspector, but I want a more generic approach.
(The model I’m using has a few clips already set on it)
Thanks in advance.

Here’s a script that loads all animation clips of a model at game start.

//it's possible that this script will not work without giving any errors.
//in that case, remove the script and add it again, don't forget to manually put the name in the name field.

using UnityEngine;
using System.Collections;
using System.Linq;

//[AddComponentMenu("System/Load Animations")]
public class LoadAnimations : MonoBehaviour {
	public new string name;
	public new string folder;
	void Awake()
		var clips = Resources.LoadAll(folder + "/" + name, typeof(AnimationClip)).Cast<AnimationClip>();
		foreach (var c in clips)
			GetComponent<Animation>().AddClip(c, c.name.Contains("@") ? c.name.Substring(c.name.LastIndexOf("@") + 1) : c.name);
		foreach (var a in GetComponent<Animation>().Cast<AnimationState>())
			a.enabled = true;
		Debug.Log ("Loaded Animations: " + folder + "/" + name + " (" + gameObject.name + ")");