I keep getting the error name 'copyDir is not defined
but it is defined as a global variable in my code. What is wrong? I reviewed some of the other posts here similar to this but still can't understand the problem. Here's the beginning part of my code:
我一直得到错误名称的copyDir没有定义,但它被定义为我代码中的一个全局变量。是什么错了吗?我回顾了这里的其他一些类似的文章,但是仍然不能理解这个问题。这是我代码的开始部分:
import arcpy, os, shutil, re
mapIndex = r'C:\Temp\temp.gdb\MapSets_All'
copydDir = r'D:\MapSheetImages\All_Images'
fields = ['FileSpecDir','is_name']
for row in arcpy.da.SearchCursor(mapIndex,fields):
arcpy.env.workspace = row[0]
rstrList = arcpy.ListRasters()
for dir, folders, files in os.walk(row[0]):
try:
if 'CCS27z2e' in folders:
for r in rstrList:
if row[1] in r:
rOrigPath = os.path.join(row[0],r)
rNewPath = os.path.join(copyDir,r)
if not os.path.isfile(rNewPath):
arcpy.AddMessage('now copying '+r)
shutil.copyfile(rOrigPath,rNewPath)
except Exception as e:
print e
arcpy.AddMessage(e)
1 个解决方案
#1
1
You have a typo:
你有一个错误:
copydDir = r'D:\MapSheetImages\All_Images'
should be:
应该是:
copyDir = r'D:\MapSheetImages\All_Images'
#1
1
You have a typo:
你有一个错误:
copydDir = r'D:\MapSheetImages\All_Images'
should be:
应该是:
copyDir = r'D:\MapSheetImages\All_Images'