cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
rverma
Level III

How to walk a directory with many sub-folders to fetch specific files?

Hello,

 

I have a folder/directory with many sub folders. In each of the subfolder there are bunch of csv files. Each csv file has a unique ID in the filename. My question is that if I have a list of IDs then how can I traverse the directory to fetch those specific csv files and concatenate them in a jmp table? Is there a way to do it with a script (JSL)? I will appreciate any guidance. CSV file name is similar to "Y123456_File_27A7Z123456.csv". String after File_ is the unique id.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to walk a directory with many sub-folders to fetch specific files?

The Files in Directory() function has a recursive option that returns the full path to each of the files found.

 

See

     Help=>Scripting Index=>Files in Directory

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to walk a directory with many sub-folders to fetch specific files?

The Files in Directory() function has a recursive option that returns the full path to each of the files found.

 

See

     Help=>Scripting Index=>Files in Directory

Jim
rverma
Level III

Re: How to walk a directory with many sub-folders to fetch specific files?

Thank you. I was able to achieve what I wanted by saving all filenames in the directory into a list.

 

filelist=Files In Directory( path1, recursive);


Then I created another list of the unique IDs.

 

unitIDlist = {"AA", "AB","AC"};


Finally I used Nested For loop to find the files that contains unique IDs in the filename and open and concatenate them to the first file.

Craige_Hales
Super User

Re: How to walk a directory with many sub-folders to fetch specific files?

also take a look at multiple file import. It may be exactly what you need.

Craige