cfdirectory single character wild card example
cfdirectory single character wild card example.
Here is an example to show the usage of cfdirectory filtering using single character wild card(?).
Description: cfdirectory manages interactions with directories.
Syntax
directory = "directory name"
action = "list|create|delete|rename"
filter = "list filter"
listInfo = "name|all"
mode = "permission"
name = "query name"
newDirectory = "new directory name"
recurse = "yes|no"
sort = "sort specification"
type = "file|dir|all">
Note: You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
Get files whose filenames have only FOUR characters followed by the 'cfm' extension type. ex:test.cfm, fun1.cfm etc
--->
<cfset filters = "????.cfm">
<cfdirectory
action="list"
directory="#ExpandPath( '.' )#"
filter="#filters#"
listinfo="name"
name="dirlist"
/>
<!--- Output file list. --->
<cfdump var="#dirlist#" label="Files with four chars">
<br>
<!--- Multiple filters:
Get files whose filenames have only FOUR characters followed by the 'cfm' extension type. ex:test.cfm, fun1.cfm etc
And
Get files whose filenames have only THREE characters followed by the 'cfm' extension type. ex:fun.cfm
And
Get ALL files with .cfc extension. ex:app.cfc
--->
<cfset filters = "????.cfm|???.cfm|*.cfc">
<cfdirectory
action="list"
directory="#ExpandPath( '.' )#"
filter="#filters#"
listinfo="name"
name="dirlist"
/>
<!--- Output file list. --->
<cfdump var="#dirlist#" label="Multiple Filters">
<br>
You can download the sample cfm file using the download button.
