<!--- 
 Filename: MultiDirectory1.cfm
 Created by: Nate Weiss (NMW)
 Purpose: Displays a list of all GIF and JPEG files in images folder
--->

<!--- 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>
 
 <cfloop query="getAll">
 <p>
 #currentRow#. #getAll.Name#<br>
 <img src="../images/#Name#"><br>
 </p> 
 </cfloop> 
</cfoutput>

</body>
</html>
