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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Looping over files/folders in a directory

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AKazak Posted - 06/01/2022 : 03:51:08 AM
OriginPro 2022b (64-bit) SR1 9.9.5.167
Windows 7 Pro SP1 x64

Greetings!

I have a folder (directory) with several tens of OTPU templates that I want to plot in bath. I want my LT script to loop over OTPU files/folders in a directory and execute the plotting code.

How do I achieve this in LT?

Thank you.

---
Andrey
6   L A T E S T    R E P L I E S    (Newest First)
AKazak Posted - 06/02/2022 : 04:09:28 AM
quote:
Originally posted by minimax

recursive:=1

In general you can run "XFName -h" to see some brief description of its variables without going to help page.



Got it!
Thanks for the hint.

---
Andrey
minimax Posted - 06/02/2022 : 01:47:16 AM
recursive:=1

In general you can run "XFName -h" to see some brief description of its variables without going to help page.
AKazak Posted - 06/01/2022 : 2:07:47 PM
Any ideas on looping over subdirectories in the target directory?

---
Andrey
AKazak Posted - 06/01/2022 : 1:44:07 PM
quote:
Originally posted by cpyang

You can use the findFiles XF.
See
https://www.originlab.com/doc/X-Function/ref/findFiles

I tested with the following very simple code to list templates that begins with B



findfiles path:=system.path.program$ ext:="B*.otp*";
int nn = fname.GetNumTokens(CRLF);

for(int ii = 1; ii <= nn; ii++)
{
	string fn$ = fname.GetToken(ii, CRLF)$;
	fn$=;
}





Got it!
This exactly what I need.
Thanks.

---
Andrey
cpyang Posted - 06/01/2022 : 1:33:48 PM
You can use the findFiles XF.
See
https://www.originlab.com/doc/X-Function/ref/findFiles

I tested with the following very simple code to list templates that begins with B



findfiles path:=system.path.program$ ext:="B*.otp*";
int nn = fname.GetNumTokens(CRLF);

for(int ii = 1; ii <= nn; ii++)
{
	string fn$ = fname.GetToken(ii, CRLF)$;
	fn$=;
}

AKazak Posted - 06/01/2022 : 04:31:45 AM
The closest command I found so far is https://d2mvzyuse3lwjc.cloudfront.net/doc/en/LabTalk/ref/GetFileName-cmd :
getfile -m *.TXT; //select multiple file.
getfile -g 2; //Get the full path of the second file.
%A=;


However this calls the GUI dialog that I don't need.

---
Andrey

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000