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
  • 31 views

jonas_nelson
Enthusiast
Forum|alt.badge.img+19

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)

View original
Did this help you find an answer to your question?

3 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • 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+19
  • Author
  • Enthusiast
  • February 10, 2021
ebygomm wrote:

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+55
  • Celebrity
  • February 10, 2021
jonas_nelson wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings