I am exporting attachments from an Table with Attachments. I want to combine 2 fields from the base table for the folder name.
This is what I have. I have named the fields FileName1 and FileName2. I just cannot figure out how to combine them
Issues is the name of the origin Table
# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2025-07-21 13:23:03
"""
import arcpy
def Model(): # Model
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
Issues = "Issues"
NRPExportTest = "\\\\gisfs01\\GIS_Cache$\\GISData\\RobertTemp\\NRPExportTest"
FileName1 = "ISSUENAME_W"
FileName2 = "WORKGROUP"
output_filename = f"{FileName1}"
# Process: Export Attachments (Export Attachments) (management)
Output_Directories = arcpy.management.ExportAttachments(in_dataset=Issues, out_location=NRPExportTest, subdirectory_field= output_filename)[0]
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(scratchWorkspace="\\\\gisfs01\\GIS_Cache$\\PortalServices\\PGIS\\FieldMarkups\\FieldMarkups.gdb", workspace="\\\\gisfs01\\GIS_Cache$\\PortalServices\\PGIS\\FieldMarkups\\FieldMarkups.gdb"):
Model()
Solved! Go to Solution.
Hey @RobertBorchert
You're pretty close from what I can see! Do something like this here:
def Model(): # Model
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
Issues = "Issues"
NRPExportTest = r"\\gisfs01\GIS_Cache$\GISData\RobertTemp\NRPExportTest"
FileName1 = "ISSUENAME_W"
FileName2 = "WORKGROUP"
# Create the folder here:
output_filename = f"{FileName1} + '/' + {FileName2}"
# Process: Export Attachments (Export Attachments) (management)
Output_Directories = arcpy.management.ExportAttachments(
in_dataset=Issues,
out_location=NRPExportTest,
subdirectory_field=output_filename
)[0]
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(
scratchWorkspace=r"\\gisfs01\GIS_Cache$\PortalServices\PGIS\FieldMarkups\FieldMarkups.gdb",
workspace=r"\\gisfs01\GIS_Cache$\PortalServices\PGIS\FieldMarkups\FieldMarkups.gdb"
):
Model()
You should be able to create a function string to add the two filenames together!
Cody
Or better yet for my purposes allow me to create a subfolder under ISSUENAME_W using WORKGROUP
Hey @RobertBorchert
You're pretty close from what I can see! Do something like this here:
def Model(): # Model
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
Issues = "Issues"
NRPExportTest = r"\\gisfs01\GIS_Cache$\GISData\RobertTemp\NRPExportTest"
FileName1 = "ISSUENAME_W"
FileName2 = "WORKGROUP"
# Create the folder here:
output_filename = f"{FileName1} + '/' + {FileName2}"
# Process: Export Attachments (Export Attachments) (management)
Output_Directories = arcpy.management.ExportAttachments(
in_dataset=Issues,
out_location=NRPExportTest,
subdirectory_field=output_filename
)[0]
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(
scratchWorkspace=r"\\gisfs01\GIS_Cache$\PortalServices\PGIS\FieldMarkups\FieldMarkups.gdb",
workspace=r"\\gisfs01\GIS_Cache$\PortalServices\PGIS\FieldMarkups\FieldMarkups.gdb"
):
Model()
You should be able to create a function string to add the two filenames together!
Cody
Thanks I will give that a shot