AnsweredAssumed Answered

Copying from a list of feature layers using python

Question asked by mehrshadx on Jul 24, 2014
Latest reply on Jul 27, 2014 by xander_bakker

I am trying to copy feature layers using the following code, but get no results. Can anyone help me understand why my code does not work?

 

import os

import arcpy

arcpy.env.workspace = ws = 'C:\\WorkSpace\\sahie_saipe\\sahie_saipe.gdb'

dictionary_Layer = {'co06_Layer':'co06', 'co07_Layer':'co07', 'cnty08_Layer':'co08', 'co09_Layer':'co09', 'co10_Layer':'co10', 'co11_Layer':'co11', 'co12_Layer':'co12', 'st_Select':'state'}

for layer in arcpy.mapping.ListLayers(mxd):

    if layer in dictionary_Layer:

        old = os.path.join(ws, layer)

        new = os.path.join(ws, dictionary_Layer[layer])

        try:

            arcpy.CopyFeatures_management(old,new,"")

            print 'copy %s to %s' %(layer, dictionary_Layer[layer])

        except:

            print 'Could not copy %s'

Outcomes