I have a folder with 3 subfolder, each having a different type of data. Folder_A and Folder_B have standard shapefiles (about 3 shapefiles in each folder). Folder_C has .tif
grid files (about 100). I am trying to write a Python script that will create the metadata files (xml) for each of these files in the subfolder. I was looking at using arcpy.SynchronizeMetadata_conversion
, but something seems awry. It looks like it is primarily designed for features in a .gdb.
Also, it doesn't have an output file. Or you cannot name one anyways. Is there another way to do this? :
import arcpy, lxml, copy, sys, os
from lxml import etree
from arcpy import env
mydir = "<file path to Spatial_Files folder>"
def list_files(dir):
r = []
for root, dirs, files in os.walk(dir):
for name in files:
print(name)
r.append(os.path.join(root, name))
return r
def list_folders(dir):
d = []
for root, dirs, files in os.walk(dir):
for dir in dirs:
print(dir)
d.append(os.path.join(root, dir))
return d
subdirs = list_folders(mydir)
for subdir in subdirs:
files = list_files(subdir)
for file in files:
arcpy.env.workspace = subdir
arcpy.SynchronizeMetadata_conversion(file, "CREATED")