List Index Out of Range

Discussion created by mgambone2 on Sep 18, 2012
Latest reply on Sep 20, 2012 by fabl

I have a batch processing script for copying multiple shapefiles in a folder into a feature dataset in a file geodatabase.  It's different from the built-in ArcToolBox in that I have to name each input feature class differently from the original names.  So I created a separator in order to split and derive the output feature class name.  The script works when I'm debugging (substituting the argv[..] variables with actual values.  But when I add the script to my Toolbox, I keep getting the error: list index is out of range.  I appreciate any assistance.  The script is as follows:

#Script Name:
#Script Path:
#Created by: Marilyn Gambone
#Date:       9/18/2012


# To batch copy multiple shapefiles in a folder into a file geodatabase feature dataset.

# Attach this script to an ArcToolBox.
# Developed in ArcGIS Desktop license version 10.0.
# Desktop computer Toolbox path:

#Name           BatchCopyRename
#Label           Batch Copy and Rename Feature Classes
#Description   Copy multiple Feature Classes from a folder into a file geodatabase
#                   feature dataset and rename each output feature class.

#Parameter List
#           Parameter Properties
#             Display Text                            Data Type                              Type         Direction    MultiValue
# argv[0]  Select Input Features               Feature Layer                           Required   Input         Yes
# argv[1]  Select Output Feature Dataset   Workspace or Feature Dataset    Required   Input         No
# argv[2]  Separator                                String                                     Optional    Input         No
# argv[3]  Output Geodatabase                 Workspace or Feature Dataset   Derived     Output       No

#Import system modules
import ConversionUtils, time = 1

#Define message constants so they may be translated easily
msgErrorInvalidOutPath = #"Output path does not exist"
msgSuccess = #" successfully converted to "
msgFailed = # "Failed to convert "

#Set script arguments
# Argument 1 is the list of feature classes to be converted
inFeatureClasses =

# The list is split by semicolons ";"
inFeatureClasses = ConversionUtils.SplitMultiInputs(inFeatureClasses)

# The output workspace where the shapefiles are created
outWorkspace =

# Get the separator ('_')
sep =

# Set the destination workspace parameter (which is the same value as the output workspace)
# the purpose of this parameter is to allow connectivity in Model Builder.,outWorkspace)

# Set the progressor
#Message "Converting multiple feature classes ...""step", , 0, len(inFeatureClasses))

#Loop through the list of input feature classes and convert/copy to feature dataset
for inFeatureClass in inFeatureClasses:
    # Set the progressor label
    #Message "Converting.." + inFeatureClass)

    # Generate a valid output name
    outFeatureClass = ConversionUtils.GenerateOutputName(inFeatureClass, outWorkspace)
    fcSplit = outFeatureClass.split(sep)
    fcName = fcSplit[2]
    outDataset = outWorkspace + "\\" + fcName.upper()

    # Execute Copy/Convert the inFeatureClasses to the outFeatureClasses
    ConversionUtils.CopyFeatures(inFeatureClass, outDataset)

    # If the Copy/Convert was successfull add a message stating this"%s %s %s" % (inFeatureClasses, msgSuccess, outFeatureClass))

  except Exception, ErrorDesc:
    # Except block for the loop. If the tool fails to convert one of the feature classes, it will come into this block
    #  and add warnings to the messages, then proceed to attempt to convert the next input feature class.
    msgWarning = msgFailed + "%s" % inFeatureClass
    msgStr =, msgStr, ErrorDesc))