Skip to main content
What is the best way to test for multiple input files on a single reader?

 

 

I have a workflow where the input is one or more files and the output filename will be based on the input filename if there is only one file but a constant if there are multiple files.

 

 

Joanna
I'm not sure about the 'best way' but two possibilities come to mind:
  • Use an Aggregator and group by fme_dataset or fme_basename. Hook in a Counter to count how many files there are. Use a VariableSetter to set the Count as a Global parameter and then a StatisticsCalculator to grab the max count . A Tester could then use the count to determine whether a static or dynamic output filename can be used. Disadvantage of this approach is of course the Group-based transformers and requirement of multiple streams of data (as Aggregator of course aggregates...). This disadvantage could be offset by having a separate reader using the Max Features to Read set as 1 and sharing the Source via a shared Published Parameter.
  • Grab the Source published parameter. Use RegEx or maybe an AttributeSplitter and/or Tester to determine whether the Source contains a * sign (which 'could' mean multiple files) or a space separating two sets of double quote encapsulted filepaths. 
There's likely a much more simple way out there but I'd personally probably go for Option 2 if I had to have it done in the next 10mins.

 


I would use a File and Path Reader to get the filenames in the inputdirectory.

Reply