To better organize data, I want to create a dictionary that takes a directory path as an argument and groups the items by datatype (for example: u'ShapeFile': ['abc.shp']). However, I run into an issue every time I try to use the describe object (desc) to classify them by dataType:

import arcpy, os, sys

inputDir = sys.argv[1]
fileList = os.listdir(inputDir)
fileDict= {}

for f in fileList:
    print f
    desc = arcpy.Describe(f)
    print "Data Type: " + desc.dataType

Every time I use this method, it throws an IOError: saying that the first item it tries to use the describe.dataType on doesn't exist.

How do I incorporate the describe function into the code so that it pulls out the dataType?


1 Answer 1


In arcpy.Describe(f) the variable f will evaluate to the filename only, without a directory. arcpy will search for that file in the 'current' directory, i.e. os.getcwd().

You need to either specify the full filename, or make sure the script runs in the correct folder.


desc = arcpy.Describe(os.path.join(inputDir, f))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.