Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

Display the Folder or directory size Coldfusion Application

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
sweetbuttercup
Asked:
sweetbuttercup
  • 2
1 Solution
 
James RodgersWeb Applications DeveloperCommented:
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
 
sweetbuttercupAuthor Commented:
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
 
James RodgersWeb Applications DeveloperCommented:
glad i could help


thanks for the points
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now