Solved

Display the Folder or directory size Coldfusion Application

Posted on 2008-06-26
3
319 Views
Last Modified: 2010-04-21
How do I obtain the folder size or the size of a directory I'm reading using cfdirectory?

I need to display the folder size or directory size
0
Comment
Question by:sweetbuttercup
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
ID: 21878324
do you want it to be recuursive and do all subdirectories?
this does it from the current directory but easy to change to a dynamic directory start
<cfdirectory action="list" directory="#expandPath('.')#" name="fileList" sort="type,name">
<cfset totalBytes =0>
<cfloop query="fileList">
<cfif #type# is "dir">
<CF_DirSize dirPath="#expandPath('.')#\#name#"> 
<cfset totalBytes =#totalBytes# + #int(evaluate(message/1024))#>
<cfelse>
<cfset totalBytes =#totalBytes# + #int(evaluate(size/1024))#>
</cfif>
<cfoutput>
#attributes.dirPath#,#name#,#size#
</cfoutput>
</cfloop>
<cfset Caller.message = totalBytes>

Open in new window

0
 
LVL 1

Author Closing Comment

by:sweetbuttercup
ID: 31471150
Very nice tag. While searching for CF_DIRSIZE, I actually found CF_FILESEARCH which is a new version of CF_DIRSIZE.  Never heard about them before. Works great!! Thanks a lot!!
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 21882626
glad i could help


thanks for the points
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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