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
 Looping over folders (mass folder rename)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ds755

57 Posts

Posted - 07/01/2021 :  09:07:24 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

ds755

57 Posts

Posted - 11/09/2022 :  06:49:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Is there any update on this? I would still like to automate this process.
Go to Top of Page

YimingChen

1683 Posts

Posted - 11/09/2022 :  10:11:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

ds755

57 Posts

Posted - 11/20/2022 :  07:48:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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$;
}

Edited by - ds755 on 11/20/2022 07:49:27 AM
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