Skip to main content

Get-File-or-Folder-List

Command Description

Specify a folder path to get a list of files or folders in the folder corresponding to the path. The list is sorted in the alphabetical order and will returned in the form of an array

Command Prototype

arrayRet = File.DirFileOrFolder(sPath,sFilter,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
sPathTruepath'''C:\Users'''To obtain the folder path of the list, you can fill in the absolute path or use @ res "path" to represent the path under the res folder of the current process. The path separator needs to be escaped, such as "C:\Laiye RPA" or @res"Laiye RPA\Laiye RPA"
sFilterTrueenum"fileandfolder"The contents of the obtained list
hasPathNonebooleanTrueIf you select Yes, each item in the returned list is the absolute path of the file or folder. If you select No, each item in the returned list is the name of the file or folder

return

arrayRet,The variable used to save the output of the command.

Demo

/********************************Get a list of files or folders************** ***************** 
Command prototype:
arrayRet = File.DirFileOrFolder('''C:\Users''',"fileandfolder",{"hasPath":true})
Input parameters:
sPath--the folder path to get the list
sFilter--The content of the obtained list (optional)
hasPath--select yes, return the absolute path of each file or folder contained in the list, otherwise only return the name (optional)
Outgoing parameters:
sName--the result after the command is run
********************************************************************************/
Dim sPath='''C:\Users\Chance\Desktop\testFile'''
arrayRet = File.DirFileOrFolder(sPath,"fileandfolder",{"hasPath":true})
TracePrint(arrayRet)