CFLib.org – Common Function Library Project

GetFileFilterCount(directory, filter)

Last updated January 4, 2012

author

James Moberg

Version: 1 | Requires: CF6 | Library: UtilityLib

Description:
Accepts a directory path & a file filter. Returns number of matching files.

Return Values:
Returns a number.

Example:

<cfset JPGFileCount = GetFileFilterCount("C:\images", "*.jpg")>
<cfset GIFFileCount = GetFileFilterCount("C:\images", "*.gif")>

Parameters:

Name Description Required
directory directory path Yes
filter filter Yes

Full UDF Source:

<!---
 Accepts a directory path &amp; a file filter.  Returns number of matching files.
 
 @param directory 	 directory path (Required)
 @param filter 	 filter (Required)
 @return Returns a number. 
 @author James Moberg (james@ssmedia.com) 
 @version 1, January 4, 2012 
--->
rsion 1, May 17, 2011
*/
<cffunction name="GetFileFilterCount" returntype="numeric" output="no">
	<cfargument name="directory" type="string" required="true" />
	<cfargument name="filter" type="string" required="true" />
	<cfset var theCount = 0 />
	<cfset var checkfiles = "">

	<cfif directoryExists(arguments.directory)>
		<cfdirectory action="LIST" directory="#arguments.directory#" name="CheckFiles" filter="#arguments.filter#" type="file" listinfo="name">
		<cfset theCount = CheckFiles.RecordCount />
	</cfif>
	<cfreturn theCount />
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson