I have an MXD as a template and about 650 folders. Each folder corresponds to a species.
What I want to do is to make an MXD (same as the template) in every folder of each species.
How to do this programmatically?
I have an MXD as a template and about 650 folders. Each folder corresponds to a species.
What I want to do is to make an MXD (same as the template) in every folder of each species.
How to do this programmatically?
This is just a pure Python solution. It assumes all your folders are within a root directory, and simply copies a specified MXD into each folder.
import os
import shutil
#change path to the MXD you'd like to copy
mxd_to_copy = "C:\\Projects\\Map.mxd"
#change to the root of where all the folders are stored
workspace = "C:\\Projects"
for dirpath, dirnames, filenames in os.walk(workspace):
for folder in dirnames:
if "gdb" not in folder:
output_folder = os.path.join(dirpath, folder)
shutil.copy2(mxd_to_copy, output_folder)
It'd probably be a good idea to put print output_folder
in place of shutil.copy2(mxd_to_copy, output_folder)
the first time to see where all the MXD will be copied.
Otherwise, I believe the only way to actually create a new MXD is through ArcObjects.