From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

recursive file list pattern

Solved!
Go to solution

Hello,

 

I have created a subvi that searches through a main folder for specific files and adds them to a compressed folder. I have 4 folders I need to create for different types of collected files (.csv and .txt). The naming convention of the files include a subject identifier, task description, and time stamp (most of the time). Here are a few examples:

 

ABC_30s_narrow_ec_12-23-42-PM_R.csv (multiple with different time stamps)

ABC_30s_narrow_ec_12-23-42-PM_L.csv (multiple with different time stamps)

ABC_sts_arms_12-21-06-PM.csv (multiple with different time stamps)

ABC_Tablet_2_12-26-56-PM.txt (multiple with different time stamps)

ABC_gait.txt

ABC_zero.csv

 

I have tried using the pattern input of the Recursive File List vi to search for a specific task (e.g. 30s) and move that to a specified compressed folder (e.g. balance). The files are only moved if the "pattern" at the end of the filename. Does the pattern only match the end of the files listed or can I get it to search for the pattern in the middle of the name? And is it possible to search for two patterns (e.g. 30s and zero) and move them to the same folder, without overwriting the compressed file? I would like to figure this out without changing the naming convention too much (predetermined by somebody else).

 

Thanks in advance,

 

Anton

0 Kudos
Message 1 of 6
(4,337 Views)
Solution
Accepted by topic author atrinh

The pattern can apply anywhere in the file name. The help specifically shows how a pattern can apply to the beginning of a filename (*.vi matches all VIs). To match specific text in the middle of the filename, you would need to use a pattern like *text* (with an asterisk both before and after the text you want to match). You can similarly match mutiple patterns with *pattern1*pattern2* .

0 Kudos
Message 2 of 6
(4,309 Views)

Thanks for the reply nathand.

 

It almost works with the exception of searching for multiple patterns. I tried using *30s*zero* to search for either files containing 30s or zero in the name but this returns zero files (should be 11 with my test folder). I tried looking in the detailed help for the vi but found no solution. Am I using the asterisks correctly for this instance?

 

 

0 Kudos
Message 3 of 6
(4,289 Views)

Ahh, sorry, I misunderstood what you meant by multiple patterns. What you want is an option or list of alternates, and that's not supported. However you can work around this easily by doing the recursive file list with several different patterns, then concatenating the resulting lists.

0 Kudos
Message 4 of 6
(4,280 Views)

Thanks!

0 Kudos
Message 5 of 6
(4,271 Views)

The OpenG List Directory Recursive does support searching on multiple patterns.  Otherwise yeah just use the native function multiple times.

0 Kudos
Message 6 of 6
(4,230 Views)