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

<cfdirectory
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.

<!--- List all files in the current directory based on the following filters:
       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.

Comments
# Posted By sdgsdgii8 | 10/10/08 1:46 AM
# Posted By sdgsdgs9 | 10/10/08 1:52 AM
# Posted By sdfsdguyut5 | 10/10/08 1:57 AM
# Posted By aasfasfasii888 | 10/10/08 2:01 AM
# Posted By pollkkid7 | 10/10/08 2:05 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. Contact Blog Owner