1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
import arcpy
import os
import fnmatch
mxd = arcpy.mapping.MapDocument ('current')
df = arcpy.mapping.ListDataFrames(mxd, "Couches")[0]
lien=r"\\BD_TOPO_2012\BD"
for dirpath, dirnames, filenames in os.walk (lien):
for filename in filenames:
if fnmatch.fnmatch (filename, '*COMMUNE*'):
tab=dirpath[73:75]
os.rename(dirpath+"\\"+filename,dirpath+"\\"+tab+filename)
for dirpath, dirnames, filenames in os.walk (lien):
for filename in filenames:
if fnmatch.fnmatch (filename, '*COMMUNE.SHP'):
addLayer = arcpy.mapping.Layer(dirpath+ "//"+filename)
arcpy.mapping.AddLayer (df,addLayer,"TOP") |
Partager