0

I'm writing a script to create a new folder and then copy a feature class to a shapefile and add the shapefile in the new folder. The folder gets created but the script is failing on the feature class to shapefile conversion line with an error of:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Output Folder: Dataset Zoning_ does not exist or is not supported
Failed to execute (FeatureClassToShapefile).

My code so far is:

import arcpy, os, datetime
from arcpy import env

# Set Workspace
env.workspace = "C:/GIS_Work"

inputFile = arcpy.GetParameterAsText(0)
outputFile = arcpy.GetParameterAsText(1)

# Create folder with today's date
#dt = str(datetime.datetime.now())

# Set local variables
out_folder_path = "C:/GIS_Work/PropertyAppraiser"
out_name = "Zoning_"

# Execute CreateFolder
arcpy.CreateFolder_management(out_folder_path, out_name)

# Execute Export Feature Class to Shapefile
arcpy.FeatureClassToShapefile_conversion(inputFile, out_name)

Is there something I need to do to the folder to make it able to receive files? I couldn't see anything in the ArcGIS Help that would suggest this, but since the folder is getting created the portion of the error that says "does not exist" wouldn't apply, I would think.

0

I decided to scrap arcpy for the create folder portion of the script and use os.makedirs instead. That worked much easier for me. My new code is:

import arcpy, os, datetime
from arcpy import env

# Set Workspace
env.workspace = "C:/GIS_Work"

inputFile = arcpy.GetParameterAsText(0)
outputFile = arcpy.GetParameterAsText(1)

# Create folder with today's date
dt = str(datetime.date.today())

newpath = r'C:\GIS_Work\PropertyAppraiser\Zoning_'+dt
if not os.path.exists(newpath): os.makedirs(newpath)

# Execute Export Feature Class to Shapefile
arcpy.FeatureClassToShapefile_conversion(inputFile, newpath)
-1

You may need to add the out_folder_path to out_name. os.path.join(out_folder_path, out_name)

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.