Skip to main content
Solved

How can I merge SHP-files with the same names from several subdirectories, into single files?

  • February 10, 2021
  • 3 replies
  • 55 views

jonas_nelson
Enthusiast
Forum|alt.badge.img+28

I have almost 100 subdirectories, each with shapefiles of the same names, eg:

/dir1/FileA.shp

/dir1/FileB.shp

/dir2/FileA.shp

/dir2/FileB.shp

/dir99/FileA.shp

/dir99/FileB.shp

 

Not only are there almost 100 directories, there are also about 30 shapefiles in each.

Is there a smart way to get an FME workbench to read all these subdirectories (they are all stored under a common "mother directory") and files, so that I can merge them into one Shapefile each?

 

What I want is to merge all FileA.shp into one file, all FileB.shp, into another, and so on.

Best answer by ebygomm

You can use a featurereader to read all shape files within a certain parent directory if you set the dataset path to something like

C:\ParentFolder\**\*.shp

You can then use the schema to dynamically write out to shape files, one per featuretype (filename)

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • Best Answer
  • February 10, 2021

You can use a featurereader to read all shape files within a certain parent directory if you set the dataset path to something like

C:\ParentFolder\**\*.shp

You can then use the schema to dynamically write out to shape files, one per featuretype (filename)


jonas_nelson
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • February 10, 2021

You can use a featurereader to read all shape files within a certain parent directory if you set the dataset path to something like

C:\ParentFolder\**\*.shp

You can then use the schema to dynamically write out to shape files, one per featuretype (filename)

Thanks @ebygomm​ , that made my day a LOT easier - just like FME should. 😃 

(Not sure that I did it by the book, but it works):

Skärmklipp_FME


hkingsbury
Celebrity
Forum|alt.badge.img+67
  • Celebrity
  • February 10, 2021

Thanks @ebygomm​ , that made my day a LOT easier - just like FME should. 😃

(Not sure that I did it by the book, but it works):

Skärmklipp_FME

nice! A good solution to this problem would to build a dynamic workflow. That way, if new (named) shapefiles are added, then you don't need to import new feature classes on your reader or create new ones on your writer

 

https://community.safe.com/s/article/dynamic-workflow-tutorial-introduction