DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script to search for special data in folder

Hi, 

 

I use several folders, which have several data called .txt at the end. Some of the folder have no .txt datas and some folder have one or two of .txt datas. 

 

I want to write a script which makes it possible for me to search for the .txt datas in the folders and let me know the Name of the data. 

 

At the moment, I have no idea how to search in folders for special data. 

 

Maybe somebody of you know how I could programme this code?

 

 

Thank you very much for your help. 

 

Best regards, 

 

Mosquito

0 Kudos
Message 1 of 9
(6,815 Views)

Hello Mosquito,

 

There is no Script required to do what you are trying to do based on my understanding of your explanation.

 

You just need to follow these two steps:

 

1. Add ALL the directories you wish to search for you *.TXT files to the DataFinder Search Areas, be selecting a grey folder in the NAVIGATOR, right-clicking the folder and then selecting "Add Search Area ...". This will ass the grey folder to the "Search Areas" = Yellow folders on top the the tree view in the "My DataFinder" view of the NAVIGATOR.

 

Mos1.png

 

2. In the NAVIGATOR panel, find the text box on top of the file system hierarchy view, and type "*.txt" into the <Enter search text> field as shown in the screen shot below. Press the "Search" button to the right of the text field, and you will get a list of all *.txt files that are contained within your yellow search area directories.

 

Mos2.png

 

That's it. No scripting required ...

 

Let me know if that helps.

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 2 of 9
(6,810 Views)

Hello Otmar, 

 

Thank you very much for your help. 🙂

 

 

I wrote a GUI where all product numbers are listed in a list box. For example A01, A02 ... I´m not sure, if I can search with the navigator for the .txt files by clicking on the product numbers listed in a list box in the GUI.

 

At the end a text field in the GUI should show me the name of the .txt file for the product number which was selected in the list box.

 

Thank you for your help. 

 

Best regards, 

 

Mosquito

 

0 Kudos
Message 3 of 9
(6,800 Views)

Hello Otmar, 

 

I selected the directory where DIAdem should search for *.txt, but in the NAVIGATOR the .txt files does not appear althrough there are some .txt datas in the folder. Do you know, if DIAdem has some special settings to view also .txt files in the NAVIGATOR?

 

Thank you in advance.

 

Best regards, 

 

Mosquito

0 Kudos
Message 4 of 9
(6,793 Views)

Hi Otmar, 

 

Sorry to bother you, but do you know how I could read the File.Folder path, like it is shown in you second picture? The name of my path is for example ... \ ...\A1. So I would like to know the last part of the File.Folder, in this case A1. 

 

In the list box of my GUI I want to click the name A1 and it should show me the File.Name of the text file for example test.txt

 

 

 

Best regards

0 Kudos
Message 5 of 9
(6,783 Views)

Hi Mosquito,

 

I'm guessing the problem you have is that you don't have a DataPlugin registered that reads your *.txt data files.  Can you load one of those data files into the Data Portal?  Can you post some of your *.txt data files for us to look at?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 9
(6,772 Views)

Dear Brad_Turpin,

 

Thank you for your answer. I have already load on eof the DataPlugin to read *.txt files. It works now.

 

I´m trying to solve this problem I mentioned in the message 5, now. I´m not sure if it works that way. 

 

 

-Mosquito

0 Kudos
Message 7 of 9
(6,762 Views)

Hi Mosquito,

 

You can use the Split function, like this:

FolderPath = "C:\D\E\F\G\H"
Folders = Split(FolderPath, "\")
j = UBound(Folders)
MsgBox Folders(j)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 9
(6,749 Views)

Thank you very much. It was very helpful! 🙂

 

 

Best regards

0 Kudos
Message 9 of 9
(6,711 Views)