2.14.1.8 findFolders

Brief Information

Search for folders

Command Line Usage

1. findFolders path:="C:\c";

2. findFolders path:="C:\c" addpath:=1;

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
path to look for subfolders path

Input

string

path$

input path to look for subfolders

add root path to all resulting folder addpath

Input

int

0

add root path to all resulting folder or not

number of sub folders found n

Output

int

<optional>

output the number of sub folders found

result folder names separated by CRLF folder

Output

string

folder$

output result file names separated by CRLF

Description

This X-Function is used to search folders in specific path and conditions.

Examples

This example shows:

  1. Opens a dialog by dlgPath X-Function to pick a path
  2. Find all subfolders under it by FindFolders X-Function
  3. Use GetToken to separate the folder names using CRLF as separator.
  4. Create same subfolder structure by pe_mkdir X-function under the current Project Explorer folder of current OPJ
dlgPath;// Open a dialog to pick path. Selected folder name will be saved in path$
type -a "You have choosen " + path$;

findFolders;// find subfolders under path specified in path$. All found path will be put to folder$, separated by CRLF, by default full path is not added

if(folder.GetLength() < 1)
{
	type "No subfolders found";
	break 1;
}
int nn = folder.GetNumTokens(CRLF);
type "$(nn) subfolders found";
string strTemp$;
for(int ii = 1; ii <=nn; ii++)
{
	strTemp$ = folder.GetToken(ii, CRLF)$;
	pe_mkdir strTemp$; //Create these folders under current folder in Project Explorer of Origin.
}

Related X-Functions

FindFiles


Keywords:root, subfolder