In a recent blog post by Ben Nadel (which should be his…oh, I don’t know…56,423rd CF tip?!) he explained that by using the pipe character you can specify multiple file extension filters on the cfdirectory tag. For example, you can do the following:
1.
That would return only Excel and CSV files. You can specify more filters by simply separating them with a pipe character. It seems like the Adobe Documentation team needs to update the ColdFusion Reference because it currently states the following for the filter attribute:
“File extension filter applied to returned names, for example, *.cfm. One filter can be applied.”
Such a helpful tip really ought to be stated in the documentation or, even better yet, used as an example. So instead, I’ll do all the work for you! Here is an example I wrote up matching the style used in the cfdirectory reference page:
The file look-up found #qUploads.recordCount# Word and Excel files in #uploadsDirectory#.
Jason Durham Said:
Thanks for sharing. :)
I guess Adobe has been too busy making fancy doo-dads to keep up on the docs! Maybe they should look into hiring Luis Majano! :)
Hatem Jaber Said:
This is a great discovery and example, thanks for sharing it, I hope Adobe sees this and updates the slim docs!
Ben Nadel Said:
@Javi,
Nicely done due. Way to fill in the documentation gaps!
Javier Julio Said:
Thanks guys! Hope this helps others out there! I could have used this myself earlier and even fellow co-worker Doug Burns pointed out the same. This is such a handy tag just never made sense that you could only provide one filter. Hopefully this gets add to the CF Reference in some form to help others!
Matthew Abbott Said:
@Javi,
Good job finding this little gem. I stumbled across this a while back, and Im glad to see it blogged on. I “assumed” it was just known. For me it was just an accident that i tried this and it worked. I need to start blogging!
Cheers man!
Matthew