Create Windows folders based on attribute value of polygon

545
2
Jump to solution
01-16-2024 02:35 AM
James_Shreeve
New Contributor III

Hi, 

Looking for any help or guidance please. I'm trying to create a windows explorer folder based on an attribute held within a file geodatabase. The use case is as below...

1) I've got a selection of polygons/sites which all need a separate project folder within a specific area within Windows explorer. Currently this being done manually, but we'll be looking to ramp up our number of sites so this will soon become untenable. Each polygon/site has it's own unique site number, which I'd like the folder name to be. 

2) I know there is a geoprocessing tool which allows you to add a new folder but this is just one and needs manual intervention in terms of folder name. Create Folder (Data Management)—ArcGIS Pro | Documentation

3) I'm a complete novice to Python but do believe this may be the best/only way to be able to do this. 

Has anyone come across similar or knows how to solve my issue please? I'd be very grateful. 

Thanks! 

James

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
EdM
by
New Contributor II

Hi

Yes - you could achieve this this through ArcPy and Python by:

1: Use an ArcPy Data Access SearchCursor() to return the values stored in a given attribute field.

2: Loop through the resulting object and for each value call the CreateFolder geoprocessing tool.

and that would work quite nicely.

But you can also achieve the same thing  through ModelBuilder. You would need to:

1: Use the Iterate Feature Selection iterator. For the In Features parameter you should choose the dataset which contains the selected records whose attributes will be used to create the folders from.

2: Add the Get Field Value utility tool to  the model and connect the Selected Features output of the iterator to the Input Table parameter of Get Field Value. You also need to specify  the attribute field of your feature layer as the Field parameter of the Get Field Value utility tool.

3: Add the Create Folder tool.

4: Connect the output of Get Field Value to the Create Folder tool specifying the Folder Name parameter. You also need to select the output folder as a parameter for the Create Folder tool.

The final model should look like the one supplied..... It took me about 5 minutes to make this. Hope it helps you out! thanks edCreateFolder.PNG

 

View solution in original post

2 Replies
EdM
by
New Contributor II

Hi

Yes - you could achieve this this through ArcPy and Python by:

1: Use an ArcPy Data Access SearchCursor() to return the values stored in a given attribute field.

2: Loop through the resulting object and for each value call the CreateFolder geoprocessing tool.

and that would work quite nicely.

But you can also achieve the same thing  through ModelBuilder. You would need to:

1: Use the Iterate Feature Selection iterator. For the In Features parameter you should choose the dataset which contains the selected records whose attributes will be used to create the folders from.

2: Add the Get Field Value utility tool to  the model and connect the Selected Features output of the iterator to the Input Table parameter of Get Field Value. You also need to specify  the attribute field of your feature layer as the Field parameter of the Get Field Value utility tool.

3: Add the Create Folder tool.

4: Connect the output of Get Field Value to the Create Folder tool specifying the Folder Name parameter. You also need to select the output folder as a parameter for the Create Folder tool.

The final model should look like the one supplied..... It took me about 5 minutes to make this. Hope it helps you out! thanks edCreateFolder.PNG

 

James_Shreeve
New Contributor III

You hero! 

Thank you so much for this, it's massively helpful and has worked a treat. I've utilised the ModelBuilder approach as I know how to work with that straight away and I added in "Select Layer by Attribute" prior to the "Iterate" function to enable me to strip down the dataset slightly when needed. Really appreciate your time in getting back to me with a solution Ed. Many thanks