<!--- Directory to scan for images --->
<CFSET Dir = ExpandPath("../images")>

<!--- First, get query object of JPEG files --->
<CFDIRECTORY
  ACTION="LIST"
  DIRECTORY="#Dir#"
  FILTER="*.jpg"
  NAME="GetJPG">

<!--- Next, get query object of GIF files --->  
<CFDIRECTORY
  ACTION="LIST"
  DIRECTORY="#Dir#"
  FILTER="*.gif"
  NAME="GetGIF">

<!--- Use CF's Query-of-Queries feature to --->  
<!--- combine the queries with a SQL UNION --->
<!--- Sort the resulting query by filename --->
<CFQUERY DBTYPE="query" NAME="GetAll">
  SELECT * FROM GetJPG
  UNION
  SELECT * FROM GetGIF
  ORDER BY Name
</CFQUERY>


<HTML>
<HEAD><TITLE>Images Folder</TITLE></HEAD>
<BODY>
<H2>Images Folder</H2>

<!--- Display all files together as a list --->
<CFOUTPUT>
  <P>There are #GetAll.RecordCount# images in #Dir#:<BR>
  <OL>
    <CFLOOP QUERY="GetAll">
      <LI><A HREF="../images/#Name#">#GetAll.Name#</A><BR>
    </CFLOOP>  
  </OL>
</CFOUTPUT>

</BODY>
</HTML>


