LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build a path with some unknowns

Solved!
Go to solution

I need to build a path to folders based on some acquired information, some constant information, and some information that will change with the acquired information. Have I confused you yet? Let me give you an example.

I have a constant folder: S:\Folder1\Code1

I have information that is being acquired: 123.456.789\987.654.321-01 (to be concatenated to the constant)

I have "unknown" information (I know what it is but the names do change): 456.567.009\aFileName.txt

This last piece I need help with. Is there a way to just say open whatever folder and file are in "this" folder?

"This" being the last folder name that is acquired: 987.654.321-01.

Overall I need the path to be:

S:\Folder1\Code1\123.456.789\987.654.321-01\456.567.009\aFileName.txt

Would be very happy to have someone point in the correct direction for this.

 

 

0 Kudos
Message 1 of 8
(2,433 Views)

In order to get all the files in a folder (even if they are below another folder) you will have to recursively find the filenames. Here is an example of how to do that:

 

Capture.PNG

0 Kudos
Message 2 of 8
(2,429 Views)

I am so sorry. I forgot to mention I am using LabVIEW 2012. I was unable to open your example.

0 Kudos
Message 3 of 8
(2,427 Views)
Solution
Accepted by topic author Jessica_2067
0 Kudos
Message 4 of 8
(2,417 Views)

Thank you that was exactly what I was looking for. Where did the "recursive get files" come from you have? In the 2012 search I found Recursive File List.vi. I would think it is similar, but due to it looking different I want to make sure before assuming it is.

0 Kudos
Message 5 of 8
(2,409 Views)

@Jessica_2067 wrote:

I need to build a path to folders based on some acquired information, some constant information, and some information that will change with the acquired information. Have I confused you yet? Let me give you an example.

I have a constant folder: S:\Folder1\Code1

I have information that is being acquired: 123.456.789\987.654.321-01 (to be concatenated to the constant)

I have "unknown" information (I know what it is but the names do change): 456.567.009\aFileName.txt

This last piece I need help with. Is there a way to just say open whatever folder and file are in "this" folder?

"This" being the last folder name that is acquired: 987.654.321-01.

Overall I need the path to be:

S:\Folder1\Code1\123.456.789\987.654.321-01\456.567.009\aFileName.txt

Would be very happy to have someone point in the correct direction for this. 

 


Constant Folder:  S:\Folder1\Code1

Known Sub-Folder:  123.456.789\987.654.321-01

Newly-created Folder and File:  456.567.009\aFileName.txt

 

Folders and Paths.png

Here is how you can use Folder Constants (useful for storing ... Folder Constants), Build Path, Strip Path, and List Folder to build up a path to the "New Folder" (456.567.009) and get a list of all the Files and Folders inside that Folder.

 

All of these functions (I think) have been around since I started using LabVIEW, with LabVIEW 7 (my only "unsure" is L01 ist Folder).  Open your LabVIEW 12 and find these functions on the F I/O Palette (you may need to look in some sub-Palettes).

 

I would strongly urge you to not use file and folder names such as 123.456.789.  They are extremely non-mnemonic!  I have a colleague who likes to name files and folders according to date and time -- talk about tedious, hard to read, hard to parse.  I recommend something like the following:

  • Start with a short "identifiable" name as a Series name.  If you expect to do this several times, put a 2-digit number after it (use leading zeros).  For example, "Bob01".
  • In the Bob01 Series, you might have multiple runs, and each run might have multiple channels.  Add a short suffix to the Folder name:  Bob01\Bob01-R01\Bob01-R01-C02.dat.  Keeping things short pays off, yet the full path name tells you exactly where it came from.
  • Generating numbered File Names is a cinch once you learn how to use "Format into String" (I never use the other XX-to-String functions once I learned Format into String).

Bob Schor

0 Kudos
Message 6 of 8
(2,405 Views)

The folder naming structure is a standard of sorts. The numbers I used were for an example, the real folder numbers make more sense. The last folder and file are within the constant/ acquired folders that I need to be found for use in another section of the overall program.

The information that has been provided has been very helpful and I have more extras to look into and learn about.

Format Into String is something I would very much like to have more details on. It seems there are things you can do with it that the help area does not go into detailed enough for me. Especially when I see some other examples in the forum.

I have been trying to figure out the best way to find the needed text file while keeping standards. I am still learning about the extra functions that LabVIEW has to offer and how to manipulate what was shown in the tutorials to fit my needs. Still new with this, but am managing to figure things out looking through this forum, LabVIEW help, and trying things. All help is appreciated.

0 Kudos
Message 7 of 8
(2,396 Views)

The one I sent you, I just coded up. The function calls itself, that's why you don't need an extra "SubVI" to go with it, it is its own SubVI!

 

Good find on the Recursive File List! I forgot that NI ships this function already, haha, use that one!

0 Kudos
Message 8 of 8
(2,386 Views)