Skip to main content
Participant
July 26, 2008
Question

count no. of files

  • July 26, 2008
  • 2 replies
  • 334 views
how could we count the no. of files (*.txt) in a directory?

a.txt
b.txt
c.doc
result should be 2.
This topic has been closed for replies.

2 replies

Inspiring
July 26, 2008
Take a look at the file management category, specifically cfdirectory. You can use its "filter" attribute to search for text files only. Then use the result set "recordCount" to obtain the total number of files found.
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags-pt0_11.html#2459859
Inspiring
July 26, 2008
use cfdirectory tag with NAME and FILTER attributes, i.e.
<cfdirectory ... NAME="myDir" FILTER="*.txt">

then #myDir.recordcount# will give you the number of .txt files in your dir.

it's all in the docs, by the way...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/