ajFolderList function
Available since AlchemyJ v4.1.3
Description
The ajFolderList function lists all files/folders information from a folder.
Syntax
ajFolderList (folder_path, [name_pattern], [recursive ], [ return_type], [return_columns],[sort_by_column_no], [sort_order], [include_header], [run_condition], [run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
folder_path (required) | String | The path of the folder. Both the forward-slash (/) and backslash (\) are supported as the folder separator. |
name_pattern (optional) | String | The regular expression to search for with file name. |
recursive (optional) | Boolean | If it equals TRUE, the function will list all the files and folders in the specified directory and all of its subdirectories in all levels. If it equals FALSE, lists all the files and folders in the specified directory only. The default value is FALSE. |
return_type (optional) | Double | It is a number value to specify the file type to be listed and returned. 0 - lists all the files and folders.1 - lists folders only. 2 - lists files only. 3 - lists read-only files only. 4 - lists hidden files only. 5 - lists hidden files and folders The default value is 0. |
return_columns (optional) | Double | It is a number value to specify the returned columns. 0 - returns Name column only. 1 - returns Name, Is Directory, File Extension, Size, Date Modified columns. 2 - returns Name, Is Directory, File Extension, Size, Date Modified, Parent Path, Full Path, Link, Read Only, Hidden columns. The default value is 0. |
sort_by_column_no (optional) | Double | The column number to be sorted. The default value is 1, sort by the first column. |
sort_order (optional) | Double | The sorting order of the return result. 0 - the result will be sorted by the specified column in ascending ordering. 1 - the result will be sorted by the specified column in descending ordering. The default value is 0. |
include_header (optional) | Boolean | If it equals TRUE, the column headers will be included in the return value. If it equals FALSE, the column headers will not be included in the return value. The default value is TRUE. |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (it can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon / Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: Table records in array format.
2) Return Type: Multiple values (array formula)
Example
This example shows the return result of ajFolderList. This is a Windows directory to be listed.
Select B13 to F22 as a result range and input the formula,
=ajFolderList(B1,,,,B5,B6,,,,B10)
use Shift + Ctrl + Enter to mke it become an array formula. The input parameter B5 is 1 and the B6 is 4. Thus, the columns Name, Is Directory, File Extension, Size, Date Modified were returned and sort by the fourth column Size.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenarios |
---|
Invalid folder path. |
Invalid return type. |
Invalid return columns. |
Invalid sort order. |