I've created 1 script to perform 2 specific tasks but it not working correctly due to how the arcpy.env.workspace
is set.
The first part of the script deletes and recreates the sub folders in "C:/EIS/SHP Files"
arcpy.env.workspace = "C:/EIS/SHP Files"
The second part of the script looks inside a particular sub folder in "C:/EIS/SHP Files/Master folder" and copies Pipe data back into the newly created folders
arcpy.env.workspace = "C:/EIS/SHP Files/Master Folder"
Problem: I can't reference 2 environments at once in a script. The script will give out an error message since it can't look in 2 paths at once. So how can we do this?
import sys
import platform
import imp
print "Importing arcpy... this may take a moment\n"
import arcpy
from arcpy import env
# Set workspace
arcpy.env.workspace = "C:/EIS/SHP Files"
# Creates the county folders
out_folder_path = "C:/EIS/SHP Files/"
# Set local variables
# List of folder values in load order
folderList = ["1","2","3","4","5"]
# Store all the folder names in a dictionary with the folder code as the
# "key" and the folder description as the "value" (folderDict[code])
folderDict ={"1":"OH_ADAMS","2":"OH_ALLEN","3":"OH_ASHLAND","4":"OH_ASHTABULA","5":"OH_ATHENS"}
# Wayne Pipe
in_data_WayneMain = "WayneMain.shp"
out_Geauga_WayneMain = "C:/EIS/SHP Files/OH_GEAUGA/WayneMain.shp"
# The Code below will utilize the [arcpy.CreateFolder_management] tool in
# order to rebuild the directory for C:\EIS\SHP Files\.. County Folders
# Process: Add valid material types to the domain
# use a for loop to cycle through all the domain codes in the dictionary
for code in folderList:
if arcpy.Exists(out_folder_path):
arcpy.Delete_management(folderDict[code])
arcpy.CreateFolder_management(out_folder_path, folderDict[code])
# The Code below will utilize the [arcpy.Copy_management] tool in order to
# copy files from the C:\EIS\SHP Files\Master Folder to C:\EIS\SHP Files..
# County Folders
# Wayne Pipe (Copied) To => County Folders
arcpy.Copy_management(in_data_WayneMain, out_Geauga_WayneMain)