2

I'm simply trying to loop through the first immediate set of folders in a directory, then the GDB's, and finally the feature classes, however, now I get "ERROR 000840: The value is not a Data Element. Parameters are not valid" for random feature class names that are being converted. For instance, it will convert one feature class named "S_WTR_LN" to lower case but will recieve the error with a feature class named "S_GEN_STRUCT". This happens when it reaches line 25, at the first arcpy.Rename_management.

UPDATE: Somehow there was a lock in arc catalog. After reseting everything, it worked -_- Final working code is below for reference.

import arcpy
import os

rootdir = r'\\server\test\ARCHIVE\\'


for subdir in os.listdir(rootdir):
    path = rootdir + subdir
    arcpy.env.workspace = path
    databases = arcpy.ListWorkspaces("*", "FileGDB")

    for database in databases:
        arcpy.env.workspace = database
        fcList = arcpy.ListFeatureClasses()
        for fcName in fcList:
            if fcName.islower():
                pass

            else:
                fcLCName = fcName.lower()
                arcpy.Rename_management(fcName, 'TEMPNAME', 'FeatureClass')
                arcpy.Rename_management('TEMPNAME', fcLCName, 'FeatureClass')
4

I'm not able to test this but I tweaked a couple things:

  1. Leave off the trailing backslashes in rootdir
  2. Use os.path.join to join rootdir and subdir
import arcpy
import os

rootdir = r'\\server\test\ARCHIVE'

for subdir in os.listdir(rootdir):
    path = os.path.join(rootdir, subdir)
    arcpy.env.workspace = path
    databases = arcpy.ListWorkspaces("*", "FileGDB")

    for database in databases:
        arcpy.env.workspace = database
        fcList = arcpy.ListFeatureClasses()
        for fcName in fcList:
            if fcName.islower():
                pass
            else:
                fcLCName = fcName.lower()
                arcpy.Rename_management(fcName, 'TEMPNAME', 'FeatureClass')
                arcpy.Rename_management('TEMPNAME', fcLCName, 'FeatureClass')

See if that works. I'm not really sure what else would be causing the error you mentioned.

5
  • Hmmm the problem I'm having now is that by using os.listdir, it lists the directory names but never traverses passed them. – TacoB0t Aug 26 '15 at 19:30
  • 2
    arcpy.ListWorkspaces requires you to set the workspace too. The way its used above, it won't have any way to know where to list the databases from. Inside your first loop, try setting arcpy.env.workspace to subdir first. – Russ Sands Aug 26 '15 at 20:03
  • Thanks, Russ! I updated the code to reflect that after also realizing that 'subdir' was not returning the actual path, just the folder name. Also updated with a new error. – TacoB0t Aug 26 '15 at 20:36
  • 1
    I updated the code, please try again. – blah238 Aug 26 '15 at 21:08
  • 1
    Thanks for your help and suggestions, blah! Got it working after getting the lock reset. – TacoB0t Aug 26 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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