使用此代码,我正在尝试读取目录及其所有子目录的所有文件。我有另一个文件名列表,如果搜索在另一个列表中的目录中找到文件,我想将这些要素类复制到另一个位置。当代码到达 FeatureClasstoGeodatabase 时,我不断收到输入要素数据类型不受支持或不存在的错误。我不确定我是否需要以某种方式获取路径和文件名,所以我创建了几个列表来分别捕获它,但我有点卡在这里:
import arcpy
import os
workspace = r'F:\SF_HMP - transferred to Ydrive'
output_loc = r'C:\temp\temp.gdb'
mssng_files = r'F:\SF_HMP - transferred to Ydrive\Maps\broken_links_missing_files.txt'
files_to_find = []
layers_list = []
layers_path = []
with open(mssng_files) as filelist:
for line in filelist:
files_to_find.append(line.strip())
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace,datatype="FeatureClass"):
for filename in filenames:
layers_list.append(filename)
layers_path.append(os.path.join(dirpath,filename))
for lyr in layers_list:
if lyr in files_to_find:
arcpy.FeatureClassToGeodatabase_conversion(lyr,output_loc)