How to batch import/export fbx files



I am a scripting newbie and I was wondering if the following thing is somehow possible to do in Maya: I have more than 100 animation fbx files of a character (just bones animation info with no mesh) and I have to add a root bone to each of them.

I already managed to make a script to add that root bone with just one click as soon as I import one of those fbx. Now the problem is that they are so many that I’d like to batch all of them.

So the process would be: import fbx, make the changes and export as fbx.

Does anyone know how could I try this or where to find more info about this?

Thank you!


You can get a list of files in a certain folder and make a loop to run commands on each of them
something like this

import maya.cmds as mc
myPath=(mc.fileDialog2(fm=2, cap=‘Select Folder’))[0]
folderContents=mc.getFileList(folder=myPath, filespec=’*.%s’ % fileType)
for x in range(0, len(folderContents), 1):
print folderContents[x]