LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read all text files in a Folder?

Hi,
Does anybody know how to do:
-Let user select a Folder, this Folder might have 3 or 4 or 20
text files. Example: C:\Folder then the VI will do the rest of the
work by reading all the files in the C:\Folder then writes/ combines
all these files into a New text file?
Thanks ahead for help.
palmtree
0 Kudos
Message 1 of 3
(3,013 Views)
Use the 'List folder' vi (File I/O -> Advanced file functions -> List folder) with a .txt filter to get an array of all the files in the selected directory.
Then read the list of files in a for loop, concatenating their contents in a shift register.
Write a new file at the end!

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 2 of 3
(3,011 Views)
Instead of simply concatenating the contents of each file into one big long string and then writing this out, I would suggest writing out each file in a loop in append mode to the new output file. This prevents the creation of one huge long string which could cause a big memory allocation.
Message 3 of 3
(3,005 Views)