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
LVL 1
sweetbuttercupAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
James RodgersConnect With a Mentor Web 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
All Courses

From novice to tech pro — start learning today.