CFML

Go to livedocs site for details, or start at MacroMedia home. If is neat that they add 'cf' to the front of their functions. And who could not like their product lineup, the names convey more -

Studio MX 2004 includes Flash, Dreamweaver, Fireworks, FreeHand, ColdFusion, Central, RoboHelp,
Director, Flex, Breeze, Contribute, Authorware, JRun, and RoboDemo ...

Back to HTML or Back to cv or to Home Page

Can not help adding some sample code, just to show what is looks like - ;-))

<h3>cfdirectory Example</h3>
<!--- use cfdirectory to give the contents of the directory that contains
this page order by name and size --->
<cfdirectory 
   directory="#GetDirectoryFromPath(GetTemplatePath())#" 
   name="myDirectory" 
   sort="name ASC, size DESC">
<!---- Output the contents of the cfdirectory as a cftable -----> 
<cftable 
   query="myDirectory" 
   htmltable 
   colheaders> 
   <cfcol 
      header="NAME:" 
      text="#Name#"> 
   <cfcol 
      header="SIZE:" 
      text="#Size#"> 
</cftable> 

Looks great to me, but then I love code, and coding ... Let me at it ;-))
But is you want just a list of folders, directories, then try -

<cfdirectory directory="C:/temp" name="dirQuery"
action="LIST">
<!--- Get an array of directory names. --->
<cfset dirsArray=arraynew(1)>
<cfset i=1>
<cfloop query="dirQuery">
<cfif dirQuery.type IS "dir">
<cfset dirsArray[i]=dirQuery.name>
<cfset i = i + 1>
</cfif>
</cfloop>
<cfdump var="#dirsArray#">
<br>
<!--- Get all directory information in a query of queries.--->
<cfquery dbtype="query" name="dirsOnly">
SELECT * FROM dirQuery
WHERE TYPE='Dir'
</cfquery>
<cfdump var="#dirsOnly#">

Reading, writting, debugging, seeing its good, correct results is what it is all about.

Back to HTML or Back to cv or to Home Page

For those who know php, here is the local server directory, output as a table -

<?php
function getDirList ($dirName, $dep) {
$d = dir($dirName);
while($entry = $d->
read()) {
$locpath = $dirName."/".$entry;
if ($entry != "." && $entry != "..") {
if (is_dir($locpath)) {
//getDirList($locpath, ($dep + 1));
$dirlist[] = $entry;
} else {
$fillist[] = $entry;
}}}
$d->close();
$totb = 0;
echo "root=".getcwd()."/.
\n";
echo "
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n";
echo "
<tr bgcolor=\"#EFEFEF\"><td>img</td><td>name</td><td>size</td><td>date/time</td><td>permissions</td></tr>\n";
if ($dirlist) {
asort($dirlist);
foreach ($dirlist as $dir) {
$locpath = $dirName."/".$dir;
$stats = stat($locpath);
$size = $stats['size'];
$totb += $size;
$filst = lstat($locpath);
$perm = TranslatePerm($filst['mode']);
echo "
<tr><td><img src=\"folder.gif\"></td><td>
".$dir."</td><td>$size</td><td><b>DIR</b></td><td>$perm</td></tr>\n";
}}
if ($fillist) {
asort($fillist);
foreach ($fillist as $fil) {
$locpath = $dirName."/".$fil;
$size = filesize($locpath);
$totb += $size;
$date = date ("F d Y H:i:s.", filemtime($locpath));
$filst = lstat($locpath);
$perm = TranslatePerm($filst['mode']);
echo "
<tr><td><img src=\"file.gif\"></td><td>".$fil."</td><td>$size</td><td>$date</td><td>$perm</td></tr>\n";
}}
echo "
<tr><td><b>Total ".$totb." bytes</b></td></tr>";
echo "
</table>\n";
}
getDirList(".",0);
?>

See the difference? ;-))