Skip to main content
Solved

How to check existing files in a folder from a transformer ? (not a Path reader)

  • July 13, 2020
  • 5 replies
  • 355 views

Forum|alt.badge.img+5

Hello everyone,

I am currently trying to get a list of existing file names inside a folder.

 

Here are some explanations :

- I have a Path reader which reads existing files in a folder (let's call it folder 1). In this folder, there should be one text file;

- If the text file exists, I use a FeatureReader to read it. This text file contains several paths to other directories (folders 2, 3, …, n).

- Once I extracted those new path, I want to do the same as with the reader : get the names of the existing files inside folders 2,...,n.

 

For now, I know how to read files from within the Workbench, with a FeatureReader.

But how can I do the exact same thing as the Path reader without using one ? I do not need to read the files right away, I just want to get the names of the files Inside folders 2,...,n.

The idea is to do all those operations in the same fmw script.

Any idea ?

 

Best answer by koen

You could use another FeatureReader with Format='Directory and File Pathnames'. It should the same as the Path reader.

 

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.

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+62

Is there a reason why you don't want to use the Path reader?

I guess you can try and do the same using a Systemcaller, on Windows the dir command, pipe that to a text file and then read that with a FeatureReader, see if the text file you need is in there and then use a second FeatureReader to read that.


koen
Contributor
Forum|alt.badge.img+14
  • Contributor
  • Best Answer
  • July 13, 2020

You could use another FeatureReader with Format='Directory and File Pathnames'. It should the same as the Path reader.

 


Forum|alt.badge.img+5
  • Author
  • July 13, 2020

You could use another FeatureReader with Format='Directory and File Pathnames'. It should the same as the Path reader.

 

It works great. I did not know I could use this format with FeatureReader. Thank you !


Forum|alt.badge.img+5
  • Author
  • July 13, 2020

Is there a reason why you don't want to use the Path reader?

I guess you can try and do the same using a Systemcaller, on Windows the dir command, pipe that to a text file and then read that with a FeatureReader, see if the text file you need is in there and then use a second FeatureReader to read that.

It should work as well but it seems a little longer and requires to generate a new text file. Since I am working on an automated process, we want to reduce the amount of temporary files between each script as much as we can, so I am going to use the other solution. Nonetheless, Thank you for your answer !


redgeographics
Celebrity
Forum|alt.badge.img+62

It should work as well but it seems a little longer and requires to generate a new text file. Since I am working on an automated process, we want to reduce the amount of temporary files between each script as much as we can, so I am going to use the other solution. Nonetheless, Thank you for your answer !

Yeah, I kinda misinterpreted what you were trying to do :)