FME Writer Configuration – How to Set FME Writer to Always Output to the Same Location as the Reader

feature-classfile-geodatabasefme-formfme-transformershapefile

Is it possible to set the Writer in FME to always write to the same location as the Reader (ideally a FeatureReader) so that the output is always saved in the same folder location as the input?

Ideally, I would like to read in a feature class from a geodatabase, and after analysis, write it out as a shapefile in the folder that the geodatabase is saved in.

Best Answer

Yes, this is fairly straightforward.

  1. Open the properties for the source feature type (table) and expose the Format Attribute called fme_dataset. That tells us the full source dataset path.

enter image description here

  1. Add a FilenamePartExtractor transformer to work on the fme_dataset value. This gets us the source dataset folder.

enter image description here

  1. Under the writer parameters open the Fanout dialog box. Set the destination folder to be the root folder and the fanout expression to the _dirpath attribute. This uses that folder as the output location of the Shapefile writer.

enter image description here

That will get you a shapefile written to the same location as the gdb folder for each gdb table:

enter image description here

Related Question