CFDirectory Multiple Filters

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.



filter="#filters#" listinfo="name" name="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.




Categories: ColdFusion

About The Author

My name is Dan Vega and I am a Software Developer based out of Cleveland OH. I love to play with new technologies and write about my experiences here. When I am not busy being a full time geek I love to lift heavy weights and hang out with friends and family. If you have any questions please don't hesitate to contact me.

Follow me on:
  • dc

    ‘ta for that, just wrote a loop for single filters, and knew there had to be a way of doing multiple filters!

  • Riyaz

    Excellent, this is what i am looking for

  • http://hfug.net John Barrett

    Thank you, I was going nuts trying to figure this out, it make it so easy, thanks!
    Johnny

  • http://mistazam.com Mistazam

    thanks so much!