If you can get it the easy way with MeshView, you (might) need to use: ID3DXAnimationController::CloneAnimationController then RegisterAnimationSet then D3DXSaveHierarchyToFile.
I done it once this way but deleted the project long time ago since i don't use dx animation system anymore, so i will guess few steps here:
Load meshes with animations.
Clone and create new animation controller :
DWORD numAllAnimations = 0;
for i = numMeshes
numAllAnimatios += mesh[i]->getAnimController()->GetNumAnimationSets();
// animCtrl is animation controller from first mesh, it doesn't matter much i just need starting point
LPD3DXANIMATIONCONTROLLER newController;
animCtrl->CloneAnimationController(
animCtrl->GetMaxNumAnimationOutputs(),
numAllAnimations,
animCtrl->GetMaxNumTracks(),
animCtrl->GetMaxNumEvents(), &newController);
Register each of their animation sets to new controller:
for i = numMeshes
for j = mesh[i].numAnimationSet
LPD3DXANIMATIONSET set;
mesh[i]->getAnimController()->GetAnimationSet(j, &set);
newController->RegisterAnimationSet(set);
then save your hierarchy to file:
D3DXSaveMeshHierarchyToFile("character_with_all_animations.x", D3DXF_FILEFORMAT_TEXT, &rootFrame, newController, 0);
That should be it.
Note that you should check all functions for failure!
EDIT:
You might want to skip registering first mesh animation sets as it is probably already included into new animation controller since we cloned it from.