2.14.2.21 pe_move

Brief Information

Move page or folder to specified folder in Project Explorer

Command Line Usage

1. pe_move move:=Book1 path:="/My Books"; // Moves workbook Book1 to the subfolder named "My Books" under the Project Explorer root folder.

2. pe_move move:="My Books" path:="/Assets"; // Moves the folder entitled "My Books" from under the active folder to a subfolder in the "Assets" folder under the project root.

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Page/Folder move

Input

string

Name of the window or folder to move.

Path path

Input

string

Path to Project Explorer folder to move the window or folder to.

Description

If the path variable is the name of a window(graph, workbook, etc), it will move the window from one folder in Project Explorer to another folder. If it is the same folder, then an error will be thrown that cannot be avoided. So care must be taken to ensure that the two folders are not the same if the X-Function is used in a script.

If the path variable is the name of a subfolder of the currently active folder in Project Explorer, it will move the folder to be under the folder specified by the path variable.

Examples

The example below utilizes four related X-Functions to reorganize an Origin project by creating and moving workbooks of imported data into folders that are named after the file extension of the files that were imported into the workbooks. The X-Functions that are used include: pe_cd, pe_mkdir, pe_path, and pe_move. Also illustrated is using the LabTalk document command as well as the String::GetFileExt()$ method.

// Use pe_cd X-function to change Project Explorer folder to the root folder for the Project.
pe_cd path:="/";

// Loop through every workbook in the project.
document -e W
{
	// Get the imported file name from page info tree of workbook (if it exists).
	string strFileName$ = page.info.system.import.filename$;
	
	// If the workboox does not contain imported data, the go to next workbook in loop.
	if (0 == strFileName.GetLength())
		continue;
		
	// Use the pe_mkdir X-Function to create a subfolder in the Project Explorer root folder named
	// after the file extension of the imported file. Note, the X-Function is specified to check
	// if the folder already exists before creating it.
	// strFolderPath$ will contain the full path once the X-Function returns.
	string strFolderPath$;
	pe_mkdir folder:="Imported %(strFileName.GetFileExt()$) Files" chk:=1 cd:=0 path:=strFolderPath$;
	
	// Now use the pe_path X-Function to get the full Project Explorer path to where the workbook currently resides.
	// strBookPath$ will contain the full path once the X-Function returns.
	string strBookPath$;
	pe_path page:="%(page.name$)" path:=strBookPath$ type:=0 active:=0;

	// Check to see if the workbook is already in the newly-created (or existing) folder by comparing the two paths.
	// If it is not, then use the pe_move X-Function to move the workbook into the folder from its current location.
	if (strBookPath$ != strFolderPath$)
		pe_move -sb move:="%(page.name$)" path:="%(strFolderPath$)";
}

Related X-Functions

pe_cd pe_dir pe_mkdir pe_path