I'm working on Arcgis 10.5 and I am trying to achieve this:
On my script, I want to make folders and subfolder, and also I want to copy one specific folder into several subfolders at the same time. My script is working well to make the folders and subfolder.
However, I get the next error when the script tried to copy the folder I want :
TypeError: cannot concatenate 'str' and 'Result' objects.
This my script:
I can't see where is the mistake so can somebody can give me a hand?
import arcpy import os import shutil #Workspaces arcpy.env.workspace = r'F:\FOLDER' Folder_to_copy = r'F:\FOLDER\FOLDER1\FOLDER2\BASE_CHIH_MZA_UTM13_2018' #<--I want to copy this folder into the subfolders Sub1,Sub2,Sub3,Sub4 #Folder to make Sub1_Folders = ['Sub1FolderA','Sub1FolderB','Sub1FolderC'] Sub2_Folders = ['Sub1','Sub2','Sub3','Sub4'] #<--The Especific folders where I want to copy my folder #Result Out_putfolder = r'F:\FOLDER\OutPutFolder' #Field dbf to make subfolder Tabla_dbf = r'F:\FOLDER\BRIGADISTA.dbf' Field1 = 'BRIGADISTA' Brigadistas = [row[0] for row in arcpy.da.SearchCursor(Tabla_dbf,Field1)] Unicos_Briga = set(Brigadistas) #Make folder and subfolders for f1 in Sub1_Folders: Sub1folder = arcpy.CreateFolder_management(Out_putfolder,f1) for f2 in Sub2_Folders: Sub2folders = arcpy.CreateFolder_management(Sub1folder,os.path.join(f2)) for tb in Unicos_Briga: tabladbf = arcpy.CreateFolder_management(Sub2folders,os.path.join(tb)) Copyfolder = shutil.copytree(Folder_to_copy,os.path.join(tabladbf)) print 'Done' This is the error show up
Runtime error Traceback (most recent call last): File "<string>", line 29, in <module> File "C:\Python27\ArcGIS10.5\Lib\ntpath.py", line 90, in join return result_drive + result_path TypeError: cannot concatenate 'str' and 'Result' objects