title: Script to list all dwg files and convert them to geodatabase
body: <p>This script is an improvement on the previously posted one but it is
  still giving me an error of "Failed to execute (CADToGeodatabase)"
  It is able to iterate through the directories and subdirectories, list
  the dwg files, create the geodatabase but not able to populate it with
  the feature datasets and feature classes due to the error!. Please help!</p>
  
  <pre><code>import os, os.path, arcpy
  from arcpy import env
  env.workspace = "J:/2010"
  # Set workspace and variables
  gdb = r"C:\data\2010.gdb"
  arcpy.env.workspace = gdb
  # Create a FileGDB for the fds
  arcpy.CreateFileGDB_management("C:/data", "2010.gdb")
  reference_scale = "1500"
  for root, dirs, files in os.walk("J:/2010/"):
      for file in files:
          if file.endswith('.dwg'):
             print "current file is: " + file
             outDS = arcpy.ValidateTableName(os.path.splitext("d" +  
             os.path.basename(file))[0])
             arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale)
  </code></pre>