LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

list of files in a folder updated automatically after each run

Solved!
Go to solution

Hi,

In my program, after each run , the VI generate a data file with auto sequencing (thanks to NI discussions). I would like to have a list (lets say 'index' file) of all this files in the folder.This index file should get updated (appended) with new filename after each run. Below attached are 'main VI' while 'datainput' and 'Folder store' are sub VI. 

thanks in advance

Download All
0 Kudos
Message 1 of 10
(3,177 Views)

Hi Jena,

 

use ListFolder to get a list of files in your folder.

Store the filenames into your "index file"…

 

Where exactly do you have problems?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,149 Views)

Hi, I tried putting List Folder the end but i do not know the data type of it. I used "spreadsheet string to array function" but did not work. 

Actually i thought of making a array with timestamp (as first column) and file name (as second column). This array will be updated each time a new file is generated in that folder.

Do write back. 

0 Kudos
Message 3 of 10
(3,118 Views)

@SanjoyJena wrote:

Hi, I tried putting List Folder the end but i do not know the data type of it.


The List Folder outputs an array of strings for the files in that folder.  What is confusing about that?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 10
(3,114 Views)

What is the purpose of this "index file"? 

Viewing a folder in windows explorer gives you a list of files and when they were created, is there a good reason to replicate this?

 

 

Ian
LabVIEW since 2012
0 Kudos
Message 5 of 10
(3,093 Views)

Hi,

Index file is supposed to be like a stack. Everytime i run my "main VI", "index fie" appends the filename to the list of filenames with timestamp.

I have tried out a way. Please check this and suggest if some better way is there.

 

The  "List Folder function" cannot be updated in every run as it shows error for 'duplicate', Rather it is useful if one wants to generate the list of filename at the end of measurement not dynamically.  

0 Kudos
Message 6 of 10
(3,070 Views)
Solution
Accepted by topic author SanjoyJena

Hi Jena,

 

this looks all so complicated…

 

What about this one:

check.png

- Why do you need to search for this "index.txt" file when you use this filepath anyway? You already enabled append mode of WriteSpreadsheetFile so new entries will ba appended to the end of the file.

- You subVI expects an array of filenames so you should create a 2D array of timestamps and filenames to append to the spreadsheet…

- Why do you use a format string of "%g" for strings? Did you read the help for those format strings?

- All your VIs will improve by using AutoCleanup…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(3,066 Views)

Hi

 

Ans1: Thanks for pointing it out. I will change it.

Ans2: for this, I changed the Loop count in "for loop" to 1, so that it runs only once in each run of mainVI. i have removed the 2D array input to simple string input.So now my subVI only expects a string not an array.

Ans3:I missed it as i copied that part from 'store VI'.

Ans4: I will do it

if any others correction are needed, do write back

 

 

0 Kudos
Message 8 of 10
(3,063 Views)

Actually , conditional for loop excepts array (in indexfilegen), but my sub VI gives string as output , so by putting this string though a "build an Array Function", it converts a string into array of dimension 1X1. This array can be given as an input to conditional for loop.

0 Kudos
Message 9 of 10
(3,061 Views)

Hi Jena,

 

creating an array from your single string (in the calling VI) is ok when the subVI is creating in a "generic" way to handle not just one new entry for the index file.

But why do you need a conditional FOR loop? And why did you set the condition to never occur?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(3,058 Views)