Skip to main content
Solved

Transform multiple files in multiple folders and create that folders at the same time.


Hi

I want to apply a transformation to all the files contained in the root folder "Vuelo84" (see attached image ). Those files are in their subfolders. I know how to load all of them in the reader, but I would like that the transformed files would be located in their own new subfolders, created by the FME itself at the same processing time. Is it possible? Thanks!

Best answer by virtualcitymatt

You will need to have a TopLevelInputFolder Parameter and an OutputFolder parameter.

 

The StringReplacer should work on the fme_dataset attribute and replace the TopLevelInputFolder with the OutputFolder. use the fme_dataset attribute as the path to the output. (you may also need to change the extension if your changing formats).

 

If using a feature writer this should work pretty well

 

 

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

3 replies

virtualcitymatt
Celebrity
Forum|alt.badge.img+39

My prefered method is by building the output file path as an attribute. You can expose an fme attribute called 'fme_dataset'. This will contain the full path to the input file. You can use a StringReplacer to replace the input path to the output path

 

So if your input files were:

C:\\topfolderinputpath\\input1\\files.ext

C:\\topfolderinputpath\\input2\\files.ext

C:\\topfolderinputpath\\input3\\files.ext

C:\\topfolderinputpath\\input4\\files.ext

 

You could replace "C:\\topfolderinputpath" with "C:\\topfolderouputpath", you would then have:

C:\\topfolderoutputpath\\input1\\files.ext

C:\\topfolderoutputpath\\input2\\files.ext

C:\\topfolderoutputpath\\input3\\files.ext

C:\\topfolderoutputpath\\input4\\files.ext

 

This attribute can then be used in a FeatureWriter as the output file location.

 

The alternative is to use the fanout option in a normal writer. It doesn't preserve the input structure and you again need some way to build the folder structure as attributes

Here is some info on using fanouts: https://community.safe.com/s/article/fanout-1#:~:text=A%20fanout%20is%20a%20way,type%20fanout%20and%20dataset%20fanout.


  • Author
  • June 15, 2021

Hi! Thanks for your answer. I think your method is ok when your structure is not large, but in my case I have 1098 folders within the root folder, each one of them with three or four subfolders. Is there any expression to put in the string replacer, so it will create the output path automatically? In the other hand, I can't see in the writer how I can select the new attribute as output location...


virtualcitymatt
Celebrity
Forum|alt.badge.img+39

You will need to have a TopLevelInputFolder Parameter and an OutputFolder parameter.

 

The StringReplacer should work on the fme_dataset attribute and replace the TopLevelInputFolder with the OutputFolder. use the fme_dataset attribute as the path to the output. (you may also need to change the extension if your changing formats).

 

If using a feature writer this should work pretty well

 

 


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