Skip to main content
Solved

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


Forum|alt.badge.img

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.

 

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

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

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+10
  • 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
  • Author
  • July 13, 2020
koen wrote:

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
  • Author
  • July 13, 2020
redgeographics wrote:

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+49
frcoud wrote:

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 :)


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