Solved

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

  • 13 July 2020
  • 5 replies
  • 26 views

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 ?

 

icon

Best answer by koen 13 July 2020, 09:23

View original

5 replies

Userlevel 4
Badge +25

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.

Badge +6

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

 

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 !

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 !

Userlevel 4
Badge +25

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

Reply