Posted on 2003-11-05
Last Modified: 2013-12-24
OK, here is the issue.

I want to loop through my directory and create the following look (SEE BELOW), I will use "wwwroot" as my base folder. I think you get the poit.  I basilcally want to create a "windows explorer" type view (although just have them all expanded).  This stuff is so easy in .asp, but being new to coldfusion.  I am at a bit of a loss.

wwwroot (dir)
    - File1.cfm (file)
    - File2.cfm (file)
    - File3.cfm (file)
      FOLDER1 (dir)
        - File1.cfm (file)
        - File2.cfm (file)
        FOLDER1a (dir)
          - File1a.cfm (file)
      FOLDER2 (dir)
        - File2a.cfm(file)
Question by:turbosig
  • 2
LVL 25

Accepted Solution

James Rodgers earned 200 total points
ID: 9691274
<cfif isDefined('attributes.dirPath')>
            <cfset path=#expandPath(#attributes.dirPath#)#>
            <cfset path=#attributes.dirPath#>
      <cfif right(path,1) eq '\'>
            <cfset path=left('#attributes.dirPath#',len('#attributes.dirPath#')-1)>
            <cfset path=#attributes.dirPath#>
<cfif not isdefined('attributes.spacer')>
      <cfset locSpacer = 1>
      <cfset locSpacer = #attributes.spacer# + 1>
try this

savt this code bloack as dirRecursive.cfm

<cfset strInset='&nbsp;'>
<cfloop index="idx" from="1" to="#locSpacer#">
      <cfset strInset = #strInset# & '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'>

<cfdirectory action="list" directory="#path#" name="fileList" sort="type desc">
<cfloop query="fileList">
<cfif #type# is "dir" and #name# neq "." and #name# neq "..">
<CF_dirRecursive dirPath="#attributes.dirPath#\#name#" spacer="#locSpacer#">
<cfoutput>#strInset#-#Name# - #size#<br></cfoutput>

and in the page that you want the directory list to appear

insert this line

<cf_dirRecursive dirPath="#expandPath('.')#" spacer="2">

the dirrecursive.cfm must be in the same directory as the page with the calling statement

Author Comment

ID: 9691422
LVL 25

Expert Comment

by:James Rodgers
ID: 9693673

glad i could help

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question