Solved

Using CFDIRECTORY

Posted on 2003-11-05
3
165 Views
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)
0
Comment
Question by:turbosig
  • 2
3 Comments
 
LVL 25

Accepted Solution

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

savt this code bloack as dirRecursive.cfm


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

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


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
0
 
LVL 2

Author Comment

by:turbosig
ID: 9691422
Thanks.
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9693673
np

glad i could help
0

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 https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) 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