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
 Batch Process
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cab0008

25 Posts

Posted - 06/07/2010 :  1:00:59 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello, I'm new to programming and need some help making a batch process (.bat) that will loop through all .opj files within a folder and subfolders and simply run an origin C file I wrote called fixit on them.

I've looked through the examples and attempted it ,but the best I can come up with is something like this:


FORFILES -p"C:\Program Files\OriginLab\Origin8\Samples\Batch Processing\" -s -m*.opj -c"-r (type "fixit"; save; exit;)"


The idea is to go through and open up every project and then just type "fixit" in the command window, save and exit.

This doesn't actually do anything though, it just appears for a second and then goes away. That would be fine if it changed the files in the process but it doesn't.

Any help would be appreciated.

Origin Ver. and Service Release (Select Help-->About Origin): 8.0.63.988 SR6
Operating System: XP

rlewis

Canada
253 Posts

Posted - 06/07/2010 :  8:28:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following Approach should work ...

typedef bool (*project_user_modify) (vector<double> &dargs, vector<string> &strArgs);

bool ModifyProjects(vector<double> dArgs, vector<string> strArgs, project_user_modify UserFunc)
{
	StringArray strOPJpaths,strFiletypes;
	strFiletypes.SetSize(2);
	strFiletypes[0]="[Origin Projects]*.opj";
	strFiletypes[1]="[Origin Projects]*.org";
	string strDlgName="Select ONE or MORE Origin Project Files";
	int NumFiles = GetMultiOpenBox(strOPJpaths,strFiletypes,NULL,NULL,strDlgName,false);
	if(NumFiles>0)
	{
		SetDataDisplayText("Project Batch Processing Begins ...");
		string strPathToProject;
		int j=0;
		vector<double> dArgs;
		vector<string> strArgs;
		for(int i=0; i<NumFiles;i++)
		{
			strPathToProject=strOPJpaths[i];
			if(strPathToProject.IsFile()==false)
			{
				SetDataDisplayText("Invalid FilePath Error ...");
				return (false);
			}
			if(Project.Open(strPathToProject)==false)
			{
				SetDataDisplayText("Project Opening Error ...");
				return (false);			
			}
			if(UserFunc(dArgs,strArgs)==false)
			{
				SetDataDisplayText("Project Modification Error ...");
				return (false);
			}
			if(Project.Save(strPathToProject)==true)
			{
				j++;
				continue;
			}
			SetDataDisplayText("Project Save Error ...");
			return (false);
		}
		string strTemp;
		strTemp.Format("%d",j);
		SetDataDisplayText("..."+ strTemp+" Projects Modified ...");
		return (true);
	}
	SetDataDisplayText("No Project Files Selected ...");
	return (false);
}

bool MyProjFunction(vector<double> &dargs, vector<string> &strArgs)
{
	/*
		
		Code for Operating on Origin Project Goes Here ...
		dArgs and strArgs can be used to transfer numerical amd string arguments to/from the Origin Projects
		On Success return ... true
		On Failure return ... false
	*/
	return (true);
}

void ExecFunc()
{
	vector<double> dArgs;
	vector<string> strArgs;
	if(ModifyProjects(dArgs, strArgs,MyProjFunction)==true)
	{
		return;
	}
}




If you incorporate your OC code to modify the projects in the space indicated, You can then compile the lot and the type the command "ExecFunc()" in the command window.
As written you should be able to navigate to the desired directories, select the projects that need modification and then execute your modification code on the selected projects.
Go to Top of Page

cab0008

25 Posts

Posted - 06/08/2010 :  09:55:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Wow you did a wonderful job on this! It's working great, it just takes a while to run through a lot of files. Thank you very much, this is going to be extremely useful in updating our files neatly.
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