Solved

Using CFDIRECTORY

Posted on 2003-11-05
3
158 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
Comment Utility
<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
Comment Utility
Thanks.
0
 
LVL 25

Expert Comment

by:James Rodgers
Comment Utility
np

glad i could help
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to configure and install nginx ? 1 403
Script 12 114
Configure IIS to process JSON 10 61
DNS, website, godaddy 6 40
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now