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.
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
Name of the window or folder to move.
Path to Project Explorer folder to move the window or folder to.
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.
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.
// 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())
// 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.
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.
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$)";