This morning I was reading an entry by
Ben Nadel on using single character wild cards. The article was a good one and I learned something new but I also posted comment saying how it would be great if we could use multiple filters.
Steve Withington posted a response showing that indeed you could do this. This of course had me a little confused because I was always told that you could only use one filter. If your not sure what I am talking about lets look at the following example. The following example reads a directory named cfgrid and does not apply any filters and therefore will list the entire contents of the directory.

As you can see from the example above the entire directory is listed. The directory contains png,cfm & cfc file extensions. If we wanted to list just the png files we could apply a filter to the results.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<cfset filters = "*.png">
<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid"
filter="#filters#" listinfo="name" name="dir">
<cfdump var="#dir#">
1<cfset filters = "*.png">
2<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid"
3filter="#filters#" listinfo="name" name="dir">
4<cfdump var="#dir#">

I was always told that you could only filter by one file extension. In fact this is right from the docs which would really back up that statement.
File extension filter applied to returned names, for example, *.cfm. One filter can be applied.
As I noted earlier you learn something new everyday. Here is an example of how to create multiple filters.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<cfset filters = "*.cfm|*.cfc">
<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid" filter="#filters#" listinfo="name" name="dir">
<cfdump var="#dir#">
1<cfset filters = "*.cfm|*.cfc">
2<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid" filter="#filters#" listinfo="name" name="dir">
3
4<cfdump var="#dir#">
This entry was posted on May 7, 2008 at 10:48 AM and has received 5428 views. Comments 3 |
Print this entry.
#1 by dc on 7/31/08 - 8:12 AM
#2 by Riyaz on 3/4/09 - 3:05 AM
#3 by John Barrett on 4/4/10 - 1:50 AM
Johnny