LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

file

Hello to all,
I need to know if, given a folder, it is possible to read only the last file of this.
In particular, I have to make a program that opens a folder and read only the last file of all the subfolders contained in it cyclically.
Someone can help me?

0 Kudos
Message 1 of 10
(2,799 Views)

I am attaching pictures of the front panel and block diagram.
I wish the program opened cyclically 3 folders in "folder name" and put the last file of each in "selected file path" (in order to create a sort of array of paths).
I make myself clear?

Download All
0 Kudos
Message 2 of 10
(2,784 Views)

You can get all the files and their information (last mod) from the Advanced File Functions Palette.

 

Example_VI_BD.png

 

<mta> Modify this example to use the Recursive File List VI to operate on all of the subfolders.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 10
(2,780 Views)

Hi Jim.
Maybe I have not explained well but I just need a loop that will open the folders one at a time and take the last file of each of them. So that later can read all the latest files.

0 Kudos
Message 4 of 10
(2,768 Views)

Give this guy a try.  I used recursion (and therefore reentrancy) to go through each folder and adding on the latest file for each folder.


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 5 of 10
(2,755 Views)

thanks to both of you but I have to find a solution to my scheme ... could you tell me how to do?

0 Kudos
Message 6 of 10
(2,747 Views)

Please clearify.  How was my code not meeting your needs?


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 7 of 10
(2,739 Views)

I've shown you how to get the last file of a folder (assuming that by "last" you mean the latest modification date).  I've further suggested that you can extend my snippet to get what you've described.  crossrulz has shown you recursion in his solution.  What more do you need?  What have you done?

 

Show me your code, Wireworker, and I'll show you mine!

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 8 of 10
(2,733 Views)

I'm sorry, I think I don't understand how your code work...

Can you explain?

0 Kudos
Message 9 of 10
(2,730 Views)

Jim's code is getting the list of files in a folder using List Folder Contents.  Using a FOR loop, he is using Build Path to create the file path and then using File/Directory Info to look at the last modified time.  The FOR loop outputs an array of these modifcation times.  He then used Array Max and Min to find the newest time and what index that time was in the array.  Using that index, use Index Array on the file list to get the name of the last modified file.

 

In my code, I used this same concept, except I added a FOR loop to go through the folders in the folder.  I had the VI call itself (well, a clone of itself) to handle the recursiveness.  My VI results in the latest file from each directory inside of the given folder.


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 10 of 10
(2,707 Views)