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 folders (mass folder rename)

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
ds755 Posted - 07/01/2021 : 09:07:24 AM
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2020 SR1
Operating System: Windows 8.1

Hello,

I am looking to write a script in order to mass rename folders. The problem is that I'm not sure which argument/label to use in the doc command so that it loops over all the folders. Here is what I've written:


[Main]

	doc -e W { // loop over all layers in project
		string oldfoldername$=%@F; //get the current folder name
		string newfoldername$ = oldfoldername$;
		newfoldername.Replace("static mode", "dynamic mode"); // replace "static mode" with "dynamic mode"
		pe_cd /; // go to the top level
		pe_rename old:=oldfoldername$ newname:=newfoldername$;
		}
}


Any help would be appreciated.
3   L A T E S T    R E P L I E S    (Newest First)
ds755 Posted - 11/20/2022 : 07:48:55 AM
Thanks! It worked! I attach the full script for whoever is interested:


string oldfoldername$;
string newfoldername$;

pe_cd;
pe_dir oname:=folders;
int n = folders.GetNumTokens(CRLF);
for (int i = 1; i <= n; i++)
{
	string tmp$ = folders.GetToken(i, CRLF)$;
	if (tmp.GetToken(1, ' ')$ == "<Folder>")
	{
		oldfoldername$ = tmp.GetToken(2, ' ')$;  //get the current folder name
		oldfoldername$ = ;
	}
	newfoldername$ = oldfoldername$;
	newfoldername.Replace("Folder", "FolderNewName"); // replace "Folder" with "FolderNewName"
	newfoldername$ = ;
	pe_rename old:=oldfoldername$ newname:=newfoldername$;
}
YimingChen Posted - 11/09/2022 : 10:11:54 AM
Maybe you can use pe_dir to get the list of folder names.

pe_cd;
pe_dir oname:=folders;
int n = folders.GetNumTokens(CRLF);
for (int i = 1; i <= n; i++)
{
	string tmp$ = folders.GetToken(i, CRLF)$;
	if (tmp.GetToken(1, ' ')$ == "<Folder>")
	{
		tmp.GetToken(2, ' ')$ =;
	}
}


James
ds755 Posted - 11/09/2022 : 06:49:02 AM
Is there any update on this? I would still like to automate this process.

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