1

I want to split a vector by an attribute but instead of getting all of them in a single folder, I need them by separate folders (say the same attribute I´m splitting, or another).

I tried splitting by attribute and then copying datasets, but I get Error 110 because the folder does not exist.

Is it possible to use the Model Builder to

  • split a feature by an attribute,
  • create a new folder for each attribute, and
  • place each new layer in the corresponding folder?

    model

  • If you want to use model builder then use the split by attribute tool to split out into separate layers but this will be into 1 folder. Then create a simple model with a featureclass iterator copying the datasets into their subfolders. Don't know what an iterator is? Read the help file. Of course this would be simpler in a python script. I'm sure there are examples here on SE. – Hornbydd Dec 17 '18 at 23:45
  • "Then create a simple model with a featureclass iterator copying the datasets into their subfolders". I know what an iterator is, but exactly how do you copy datasets into their subfolders? – Alfonso de Lara Dec 18 '18 at 13:52
  • You are getting that error because the folder does not exist! You need to create the folder then copy the dataset into it. – Hornbydd Dec 18 '18 at 14:54
  • But if I have to create every folder by hand, there´s no point on doing iteratios. What I need to do is to split a feature by an attribute, and for each attribute create a folder with its name. Is it possible? – Alfonso de Lara Dec 18 '18 at 15:21
  • Even though it is marked as DUPLICATED, I believe nobody solved my issue yet. Thanks, – Alfonso de Lara Dec 18 '18 at 18:51
0

It's easy to create the folder before you copy a dataset into it, you are already using inline substitution in the copy tool, why not use inline substitution for creating the folder...

By making the Create Folder tool a precondition to the copy tool this means it must run before Copy. So now you have a folder to copy into.

Model

The text in purple is what you would put into the output data element in the Copy tool.

  • Thanks @Hornbydd. Even tough it helps, it does not address my issue. The "split by attribute" has a workspace as an output folder (so I don´t get a name foe each processed file). Does somebody know a good tutorial or course about model builder "naming" or file creation steps? Thanks in advance – Alfonso de Lara Dec 19 '18 at 20:22
  • As you correctly identify split by attribute output is a workspace. I'm suggesting you simply run that tool by itself, then using the model above you manually set the Folder input as you know what the folder is. If you wanted to encapsulate it all in a model then the above model is a sub-model in a master model with only the split by attribute tool. You would need to expose the folder as a parameter for that to work. If you don't know what a sub-mode is, then its time for you to read the help file! – Hornbydd Dec 20 '18 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.