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:
DWORD numAllAnimations = filePath.size();
LPD3DXFRAME frameRoot, othersFrameRoot;
D3DXLoadMeshHierarchyFromX(filePath, D3DXMESH_MANAGED, device,
memoryAllocator, NULL, &frameRoot, &animController);
for(UINT i = 1; i < filePath.size(); i++) // note that we skip first
D3DXLoadMeshHierarchyFromX(filePath[i], D3DXMESH_MANAGED, device,
memoryAllocator, NULL, &othersFrameRoot, &animController);
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.
Edited by belfegor, 05 July 2013 - 01:58 PM.