title: importing and renaming multiple objects in maya with python
body: <p>I am trying to import multiple object files in maya using python and use the file name as object name in maya. I have managed to import the objects, but I have only been able to use the file name as a namespace  and not as a object name.</p>
  
  <pre><code>import maya.cmds as cmds
  
  def import_multiple_object_files():
      files_to_import = cmds.fileDialog2(fileFilter =  '*.obj', dialogStyle = 2, caption = 'import multiple object files', fileMode = 4)
      for file_to_import in files_to_import:
          names_list  = file_to_import.split('/')
          object_name = names_list[-1].replace('.obj', '') 
          cmds.file('%s' % file_to_import, i = True, type = "OBJ", namespace = object_name, mergeNamespacesOnClash = False, ignoreVersion = True, options = "mo=0",  loadReferenceDepth  = "all"  )
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/crybS.png" alt="http://i59.tinypic.com/2eoabgm.png"></p>