From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read subfolders and files in those subfolders

Solved!
Go to solution

Is there a way to read all the subfolders inside a folder, all the files in those subfolders, and obtain the folder name of the last subfolder?

Any example will be greatly appreciated.

I tried something but it soesn't work.

Please help me.

Thanks in advance!

0 Kudos
Message 1 of 6
(4,358 Views)
Solution
Accepted by topic author Nando88

Recursive File List VI

 

Owning Palette: Advanced File VIs and Functions

 

Lists the contents of a folder or LLB. In order for this VI to work correctly, the LLB must have a .llb file extension.

 

http://zone.ni.com/reference/en-XX/help/371361H-01/glang/recursive_file_list/

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 2 of 6
(4,353 Views)

never ming. I just figured out that I can truncate the path.

Thank you very much.

0 Kudos
Message 3 of 6
(4,349 Views)

How would I get the last folder name?

0 Kudos
Message 4 of 6
(4,322 Views)

Hi Nando,

 

depending what you understand as "last folder" you can either use IndexArray to get the last element in the "All folders" array or you use StripPath to get the last part of a file path…

 

You know asking questions with some meaningful examples of "before" and "after" greatly helps to get better answers!?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(4,316 Views)

Last could infer some form of sorting or priority to select only one folder from a group of folders in a folder that have no sub-folders (that even confuses me when I read it) , you really do need to be more specific in your requirements.

 

If you mean the names of all folders that have no sub-folders, then you can use the function you started with combined with the recurisive list function I pointed you to.

 

Specify a folder, use recursive list to get all sub-folder names, then iterate over the list and determine the number of sub-folders in that specific folder. If zero, use conditional terminal on auto-indexing tunnel to add to a list of folders with no sub-folders.

 

Deepest Folders.png


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 6 of 6
(4,274 Views)