Skip to main content

Hi

I've tried following the recipe in this article https://community.safe.com/s/article/Using-the-Directory-and-File-Pathnames-Reader-Record-File-Metadata for reading metadata on a bunch of shape files stored in different subfolders (one *.shp per folder) in parent folders in a collective project directory.

All the shape files (54 in total) have the same file name "Vejle.shp" with similar attributes in them. So I only have the distinct [parent-folder/subfolder] names to identify them from another. My goal is to use the the outcome metadata for renaming all the shapefiles so they are matching the folder names.

Or even better: directly write a new attribute to the files based on the respective input folder name as i transform and load my data from shape into one feature class in an ESRI file geodatabase.

How do I do that?

Hi @thard

The Directory and File Pathname reader method used in the article you linked would be suitable for renaming the file if used in combination with the File Copy writer.

For getting the distinct parent folder/subfolder value, you can use two consecutive FilenamePartExtractor--one to get the subfolder and the other to get parent directory from the path_windows attribute. Alteratively, you can also use a StringSearcher if you are familiar with Regex to get parent folder/subfolder.

If you wish to add a new attribute to the shapefiles, then you will need to use the Shapefile reader to read the shapefiles. Expose the fme_dataset format attribute and use either the FilenamePartExtractor or StringSearcher.


Reply