Skip to main content
Solved

How do I use the current filename as a variable whilst iterating through a directory?

  • January 15, 2019
  • 4 replies
  • 144 views

Forum|alt.badge.img

I am processing a directory of XML files. I have set the source dataset to just .../*.xml

However, I would like to save the results according to the source Filename. How do I set the output filename to be the same as the input filename?

Best answer by dewan

@robertdbuckley Click on the settings icon on your reader and select the Format Attributes tab. Check the fme_feature_type. Now, go to the writer properties and in the Name option, click on the downward triangle button and from Attribute value, select fme_feature_type. Now, from the Navigator pane, drop down the writer and open the Fanout Expression and select fme_feature_type from there.

The output will be in the defined folders.

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

4 replies

Forum|alt.badge.img
  • Best Answer
  • January 15, 2019

@robertdbuckley Click on the settings icon on your reader and select the Format Attributes tab. Check the fme_feature_type. Now, go to the writer properties and in the Name option, click on the downward triangle button and from Attribute value, select fme_feature_type. Now, from the Navigator pane, drop down the writer and open the Fanout Expression and select fme_feature_type from there.

The output will be in the defined folders.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • January 15, 2019

I think for xml files you will need to expose the fme_basename, this can then be used to set the name in the writer


david_r
Celebrity
  • January 15, 2019

In addition to what the others said, here's the documentation (what you're looking for is called a "fanout" in FME):

http://docs.safe.com/fme/2018.1/html/FME_Desktop_Documentation/FME_Workbench/Workbench/Setting_Dataset_Fanout_Properties.htm


Forum|alt.badge.img
dewan wrote:

@robertdbuckley Click on the settings icon on your reader and select the Format Attributes tab. Check the fme_feature_type. Now, go to the writer properties and in the Name option, click on the downward triangle button and from Attribute value, select fme_feature_type. Now, from the Navigator pane, drop down the writer and open the Fanout Expression and select fme_feature_type from there.

The output will be in the defined folders.

Thanks for the replies. I was trying to find the way to expose the basename and your method worked. I just used basename instead of featureclass.


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