Question

Modifying Output File Name Dynamically

  • 28 February 2013
  • 5 replies
  • 31 views

Hello Everyone,

 

     I am completely new to the FME world and I am trying to get started by working on a project that can take me hours to do manually.  My first step is finding a way to change the output filename based on the output folder.  For example I want to save a file to C:\\RAN Files\\Cell Ref Work\\MapInfo\\2013_02_21

 

Right now I have the output filename set to GSM_Sectors

 

I would like to have the filename be GSM_Sectors_2013_02_21

 

So if the folder was C:\\...\\2012_07_04 then the filename would be GSM_Sectors_2012_07_04 any thoughts?

5 replies

Userlevel 2
Badge +17
Hi,

 

 

Destination dataset name is saved as a Published Parameter named "DestDataset_***" by default. When the destination format is file-based one, the destination dataset name is the output folder path which was set by user. Using the Published Parameter, several transformers and the fanout function would help you, for example:   1) Add an attribute retaining the output folder path to each feature by AttributeCreator: Attribute Name: _folder_path Value: $(DestDataset_***) $(...) means value of a Published Parameter, you can get output folder path by linking to "DestDataset_***" parameter.   2) Split the folder path string at the delimiter by AttributeSplitter: Attribute to Split: _folder_path Delimiter of Format String: \\ List Name: _list   3) Get the last element of _list (i.e. folder name) by ListIndexcer: List Attribute: _list{} List Index: -1 "-1" indicates the last element index of the list, so _list will retain the folder name.   4) Create preferable output file name by StringConcatenator: Destination Attribute: _output_name String Parts: (Constant)   GSM_Sectors_ (Attribute Value)  _list   5) Set fanout attribute on the writer: Check Funout By Attribute checkbox and select _output_name.

 

Hope this helps.
Badge +10
Alternatively if you want to avoid the list you could just use a FilenamePartExtractor to grab the folder name from the DestDataset parameter and then use that in the StringConcatenator.
Hello,

 

 

you can use the dataset fanout option in the advanced writer options in the navigator.

 

 

First I set up my workspace -> generate workspace -> create reader and writer

 

 

Then I put in a TimeStamper to assign a date to an attribute.

 

 

In the next step I use a StringConcatenator to bring together fme_basename and the value of the TimeStamper (-> @Value(fme_basename)_@Value(_timestamp))

 

 

 

Now I got to the Dataset fanout in the navigator.

 

As fanout directory I use a general output folder:

 

C:\\FMEData\\FMEData\\Data\\Transit\\out

 

 

In the 'attribute to fanout on' I use my _concatenated result form the string concatinator

 

 

In my case I use Shape and I get an Output folder with subfolders that have

 

the fme basename and the timestamp

 

-> BikeRoutesH_20130301

 

 

I hope this approach will help you,

 

best regards,

 

Stefan

 

Thank you for all the responses I was able to get the output just the way I wanted it.  

 

 

Sincerely,

 

EM
Badge
Thank you, 1SpatialDave, it worked well for me.

Reply