You have to put CloneAnimationController before loop so it is cloned only once. To make it easy for me to explain with little code as possible i am gonna assume you have only one animation set in each x file, then you could improve it later for multiple animations per x file when you got this working:
vector<LPCSTR> filePath;
filePath.push_back("walk.x");
filePath.push_back("die.x");
filePath.push_back("idle.x");
filePath.push_back("crouch.x");
filePath.push_back("wave.x");
filePath.push_back("jump.x");
DWORD numAllAnimations = filePath.size();
LPD3DXFRAME frameRoot, othersFrameRoot;
LPD3DXANIMATIONCONTROLLER newController;
LPD3DXANIMATIONCONTROLLER animController;
D3DXLoadMeshHierarchyFromX(filePath[0], D3DXMESH_MANAGED, device,
memoryAllocator, NULL, &frameRoot, &animController);
animController->CloneAnimationController(animController->GetMaxNumAnimationOutputs(),
numAllAnimations,
animController->GetMaxNumTracks(),
animController->GetMaxNumEvents(),
&newController);
for(UINT i = 1; i < filePath.size(); i++) // note that we skip first
{
D3DXLoadMeshHierarchyFromX(filePath[i], D3DXMESH_MANAGED, device,
memoryAllocator, NULL, &othersFrameRoot, &animController);
LPD3DXANIMATIONSET set;
animController->GetAnimationSet(0, &set);
newController->RegisterAnimationSet(set);
}
delete memoryAllocator;
memoryAllocator=0;
hr = D3DXSaveMeshHierarchyToFile("G:\\character_with_all_animations.x", D3DXF_FILEFORMAT_TEXT, frameRoot, newController, NULL);
I am not sure if CloneAnimationCotroller will copy animation set in new controller from one that with cloned from, since MSDN docs are incomplete and obscure, so you need to test that.
As always check all functions for failure, i removed it for readability. Also there is some memory leaks here but it doesn't matter much you can fix that later until you got this working first.