Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: Read files based on date selection

$
0
0

So I'd say start with a cfdirectory of the whole directory, to get all the files.  This returns a query object.  You can then use this to do a query-of-queries on, e.g. based on your date criteria. 

 

<cfset form.yearFrom = 2010> 

<cfset form.yearTo = 2012>

 

<cfdirectory name="getAllFiles" directory="/your/folder/" type="file" filter="*.txt">

 

<cfquery name="getYearFiles" dbtype="query">

  SELECT *

  FROM getAllFiles

  WHERE 1=0

  <cfloop index="i" from="#form.yearFrom#" to="#form.yearTo#">

    OR  name like 'text#i#%'

  </cfloop>

</cfquery>

 

<!--- loop over getYearFiles, read each file --->

 

<!--- if year = current year, just read 'text' --->

<cfif form.yearTo EQ year(now())>

  ...

</cfif>


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>