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
  • 171 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.

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.

4 replies

Forum|alt.badge.img
  • 39 replies
  • 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+44
  • Influencer
  • 3422 replies
  • 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
  • 8391 replies
  • 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
  • Author
  • 41 replies
  • 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.

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.