IPA to find files in subfolders

 10 Replies
 2 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Srini Rao
Veteran Member Send Private Message
Posts: 149
Veteran Member

Hello - How do I find all files under a given subfolder.

 

Example: d:/main/folder1/file1.csv

                d:/main/folder1/file2.csv               

                d:/main/folder2/file1.csv

               d:/main/folder2/file3.csv etc...

 

I'm looking for a node which will give me all files under main folder and sub folders .

 

 




Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
Hi Srini Rao - the FileAccess node as a "List Files" option. I think that's what you're looking for.
Kelly Meade
J. R. Simplot Company
Boise, ID
Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
Sorry, I'm wrong. Actually, this will list the files within the designated folder but it will not show subfolders or files within subfolders. Instead, I think you'd need to use the System Command node to get all files and folders.
Kelly Meade
J. R. Simplot Company
Boise, ID
Srini Rao
Veteran Member Send Private Message
Posts: 149
Veteran Member
Thanks, I tried ListFiles but did not work, let me use the system command to get the list.

Thanks
Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
I was able to do it with System Command using command "dir {path} /s /b /a-d" This lists files recursively, excludes headers/footers, and excludes directory entries. I then followed that with a DataIterator node to separate the returned data into individual records.
Kelly Meade
J. R. Simplot Company
Boise, ID
Srini Rao
Veteran Member Send Private Message
Posts: 149
Veteran Member
I used the /s /b and it worked thanks
Srini Rao
Veteran Member Send Private Message
Posts: 149
Veteran Member

Another question, I have text file, How do I read the text file in my program.

 

 

Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
It depends what you need to do with the file's contents.

If you want all the contents at once, you would use the FileAccess node in "read" mode. You pass in the path/filename (must be a path that the server can see directly - i.e. not a UNC path) and it will return the contents of the file into the node_output variable.

If you need to parse the file (I.e. process a csv file) you would use the DataIterator node with input method "file" (same file location limitation as above) to parse the data by line, then pass the output from that node into another DataIterator node with input method "data" to parse it by delimiter or column.
Kelly Meade
J. R. Simplot Company
Boise, ID
Srini Rao
Veteran Member Send Private Message
Posts: 149
Veteran Member
Thanks Woozy , I was able to use "read from file" and it returns me all records. But how do I process a record at a time. Sorry Again....

I need to process the individual records. :-)

Thanks Again.

Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
Read the second paragraph of my previous response. That answers your question.
Kelly Meade
J. R. Simplot Company
Boise, ID
Srini Rao
Veteran Member Send Private Message
Posts: 149
Veteran Member
I missed it Thanks Again.

let me try.