I cant write everything down, but here are some guidelines to avoid problems such as this.
Try to have more organized code. Separate your UI creation commands from your working procs
NEVER have UI elements created without a fixed name. What's the point of creating a textfield with a random name? How can you refer to the data it holds? I can see what you are doing with storing the name on the $tf1 at once, but it is way cleaner and manageable to write the name in the creation command. Also it is so much easier to query the textfield.
Your string variable $tf1 is undeclared. If you were to run the exact code you post here on a fresh maya session it would not work.
You dont need to create a window, use the filebrowserdialog in directory mode to get the name of the folder, and store the path to a string.
Then use a prompt dialog to input the filename of the obj to be exported.
In a nutshell (look in the MEL command reference for the flags and options )
global proc exportObj ()
{
string $path = fileBrowserDialog
;
string $name = promptDialog
;
//use the export command
}
Check what the $allMeshes stores inside. I have a feeling that the way you have it written, it stores shape name and not the trensform name. If so, use a listRelatives -parent to get the transform, cause that's what you need to use in the export command.
I'm sorry I can't check your code right now to spot the problem. If I have any flaws in the above please correct me.