?
Solved

Using CFDIRECTORY

Posted on 2003-11-05
3
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 800 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 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