The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Importing data from subfolders
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

andy.zld

USA
1 Posts

Posted - 01/29/2019 :  11:01:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I want to write a script, which imports data files form subfolders. Data files form each subfolders are placed in separate worksheet, renaming worksheet with folder name. How with OriginScript get list of subfolders in specified folder?

yuki_wu

896 Posts

Posted - 01/30/2019 :  04:04:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
You could try to use findfiles X-Function:
https://www.originlab.com/doc/X-Function/ref/findFiles

I wrote a simple example:


strPath$ = System.path.program$ + "Samples"; 
findfiles path:=strPath$ ext:="txt" recursive:=1 fname:=results$;
int nn = results.GetNumTokens(CRLF);
int nFlag = strPath.GetNumTokens("\");
for(int ii = 1; ii <= nn; ii++)
{
	strFile$ = results.GetToken(ii,CRLF)$; //Get Import File
	strFile.GetToken(nFlag+1, "\")$=; //Get the name of subfolder under the strpath$
}


Hope it helps.

Regards,
Yuki

OriginLab
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000