AnsweredAssumed Answered

Collapsing a folder structure into a single folder

Question asked by geonetadmin on Sep 17, 2013
Original User: dan_h_b

Hi all,
I have a single folder, let's call it Folder1, which contains multiple folders; FolderA, FolderB, FolderC.....FolderZ.
Folders A-Z each contain multiple file geodatabases.  Folders A-Z do not contain any other file type or any other folders.
I need to copy all the of the file geodatabases which are in folders A - Z into a single folder elsewhere on my local drive.

I am trying to do this in model builder as I have very little experience of python.

I thought that I would be able to easily achieve this by using a model (attached image "MainModel")and a submodel ("SubModel")

My main model has a folder variable set as the input parameter (this would be Folder1).  This feeds into an Iterate Workspaces iterator.  I have set this to only look for folders (here I want it to return FolderA, FolderB, FolderC....FolderZ).

I use the output workspace from here to feed into my submodel as a parameter.

The submodel has a folder parameter as the input (this is the "Workspace" from MainModel, in theory this should be FolderA, FolderB etc....).  This then feeds into an iterate workspaces iterator and looks for FileGDB's.  The "Worksapce" output then feeds into the copy tool which copies the geodatabase into a predefined folder on my local drive.

I can run the SubModel on its own and it works fine, i.e. I can point it to Folder A and it will copy all of the file geodatabases from FolderA into another folder.  The problem arises when I try and work from the MainModel.

In MainModel, I can connect the "Workspace" output into the SubModel and it let's me select the "Folder" variable for this.  However, the model doesn't fill with colour, and if I open the tool parameter window I see the error (attached "Error840" file).

I've tried changing the variables in each model to be folders or workspaces or a combination, and I've tried setting the iterators to look only for folders or only for GDB's or I've even left the "Workspace type" field blank.  But nothing seems to work.

The only thing I've managed to do where I've had partial success is using a single model (attached "AlternateModel").  This uses the recursive option in the iterator properties and has Folder1 as the input Folder variable parameter.

This copies all the geodatabases as required from all the folder (A-Z), however, it also copies all the folders (A-Z).

Is there something simple which I am missing?  Or is this not possible to do?

Many thanks to all.