AnsweredAssumed Answered

Rename a list of SHP files in Python

Question asked by franciscosobrado on Sep 8, 2015
Latest reply on Sep 8, 2015 by wwmiller68

Hello people,

 

I have a list of SHP files that I want to rename. First, I want to replace the "." from the shp to "_", and then rename the file. As you can see in the image below:

 

 

This the code that I am using:

 

import arcpy, os

 

arcpy.env.workspace=r'H:\WWF\0_GeoDatabase_GIS\6_Especies\Conejo\Seguimiento\Cuadriculas\WWF\Andujar\2012\RAMON_1'

 

for filename in arcpy.ListFeatureClasses():

  

    a=filename.replace('.', '_')

    a="shp_"+a

    arcpy.Rename_management(filename, a)

   

    print "ok"

 

The problem is that when I am trying to open the SHP file it does not work. I am getting the following error message:

 

 

Does anyone knows how to fix the problem...

 

Thanks for your help

Outcomes