Get Folder Size (Desktop)

written by jdefilip

I’m trying to build an Analyses to show the desktop size… So far this is what I found from another post, the results are showing up as none?

Anyone have any idea’s?

(pathnames of it ,((sum of sizes of descendants of it)/1000) as string & " MB") of folders “Desktop” of folders of folders of folder “c:\documents and settings”

Thanks!

written by Tim.Rice

Too many “
of folders
”?

The following clause works on my Win7 machine …

(pathnames of it ,((sum of sizes of descendants of it)/1000) as string & " MB") of folders “Desktop” of folders of folder “c:\users”

replace “
C:\users
” with “
C:\Documents and Setting

I suggest you NOT set this Analysis property to evaluate at “Every Report”. If there are either a lot of users on a system, or someone has a very large desktop folder, it will cause adverse client performance. I’d recommend, no more frequently than every 6 hours.

written by jdefilip

This seems to work pretty well. Is there a way to modify this Relevance to only target the most recent modified and 3 largest profiles? I have seen that in the past with other Analyses, I have it set to evaluate every 1 day.

(pathnames of it ,((sum of sizes of descendants of it)/1000) as string & " KB") of folders “Desktop” of folders of folder “c:\documents and settings”

Thanks!

written by Tim.Rice

I don’t know of anything that will let you sort the items. Doesn’t mean it’s not possible, I just don’t know it.

Another option might be to only return non-0 sized folders.

((pathnames of it ,((sum of sizes of descendants of it)/1000)) of folders “Desktop” of folders of folder “c:\documents and settings”) whose (item 1 of it > 0)

I dropped the conversion to string to allow a simpler size check in the Whose clause. If you require the value be returned as a string with " KB" appended, try …

((pathnames of it ,((sum of sizes of descendants of it)/1000) as string & " KB") of folders “Desktop” of folders of folder “c:\Users”) whose (substring before " KB" of (item 1 of it) as Integer > 0)

written by jdefilip
Thanks Tim, the non-0 sized folder addition definitely cleaned up the report. Do you know of any way to only find the largest desktop folder?

((pathnames

of

it

,
((sum

of

sizes

of

descendants

of

it
)
/
1000000
))

of

folders

“Desktop”

of

folders

of

folder

“c:\documents and settings”
)

whose

(
item

1

of

it

0
)

written by Tim.Rice

I want to think that there is some way to use the UNIQUE VALUE OF inspector since the documentation indicates that it sorts the objects, but I’m still learning to use sets in relevance. Maybe someone else could chime in?

written by jgstew

This is possible using single recursion:

(pathname of it, sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder) of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder

I generalized this to work with both WindowsXP and WinVista+, tested only on Win8. I also used “drive of system folder” instead of hardcoding “C:”, which is probably unnecessary.

written by jgstew
This will break the sorting in the console, but it will put the correct unit size at the end of the value.

(pathname of it, (if (0<(it / (1024102410241024))) then (it / (1024102410241024)) as string & " TB" else if (0<(it / (102410241024))) then (it / (102410241024)) as string & " GB" else if (0<(it / (10241024))) then (it / (10241024)) as string & " MB" else if (0<(it / (1024))) then (it / (1024)) as string & " KB" else (it as string & " B")) of sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder) of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder

written by jdefilip

Jgstew, thank you for the reply. This seems to work for Win7 systems in our environment, however XP machines are showing the result property as . Any idea what needs to be changed?

(pathname of it, (if (0<(it / (1024102410241024))) then (it / (1024102410241024)) as string & " TB" else if (0<(it / (102410241024))) then (it / (102410241024)) as string & " GB" else if (0<(it / (10241024))) then (it / (10241024)) as string & " MB" else if (0<(it / (1024))) then (it / (1024)) as string & " KB" else (it as string & " B")) of sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder) of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder

Thanks!

written by jgstew

I don’t really have any Windows XP machines to test this with.

Does the following work?

(pathname of it, sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder) of folders of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder

How about this, which should only work on XP:

(pathname of it, sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders of (folder “c:\documents and settings” of it) of drive of system folder) of folders of (folder “c:\documents and settings” of it) of drive of system folder

written by jdefilip

Same result for XP machines.

written by jgstew

I may have found part of the problem, but what version of the client are these XP machines running?

what is the output of the following on an XP machine? :

folders whose(exists folder “Desktop” of it) of (folder “c:\documents and settings” of it) of drive of system folder

This may work:

(pathname of it, sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder) of folders whose(exists folder “Desktop” of it) of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder

written by jdefilip
The XP machines are all on Agent Version 9.0.787.0.

Still receiving as the output for:

folders whose(exists folder “Desktop” of it) of (folder “c:\documents and settings” of it) of drive of system folder

Received the output on XP machines for:

(pathname of it, sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder) of folders whose(exists folder “Desktop” of it) of (folder “c:\documents and settings” of it | folder “users” of it) of drive of system folder

-Thanks

written by jgstew

I just realized there was the “C:” in the XP version. I’m pretty sure that was the issue.

Try:

folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it) of drive of system folder

This should be it:

(pathname of it, sum of sizes of descendants of it) of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder) of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder

written by jdefilip

That works great! Two questions:

-Can the result conversion be dropped

-Can the result be in a separate property

Property Result:

C:\documents and settings\jdefilip\Desktop, 122112012

written by jgstew

I’m not exactly sure what you mean with your 2 questions. Can you give me an example result of what you would like it to look like?

This would give you the size only:

sum of sizes of descendants of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder) of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder

This should give you only the path:

pathnames of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder) of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder

written by jdefilip

This is exactly what I was looking for to display the Path and the folder size separately. I used a formula in excel to drop the conversion to MB.

Thanks!

written by jgstew

This will get you the size in MB:

(it / (1024*1024)) of sum of sizes of descendants of folders “Desktop” whose(sum of sizes of descendants of it = maximum of (sum of sizes of descendants of it) of folders “Desktop” of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder) of folders whose(exists folder “Desktop” of it) of (folder “documents and settings” of it | folder “users” of it) of drive of system folder

written by jgstew

I added this to my “Hard Drive Audit - Windows” analysis found here:

http://bigfix.me/analysis/details/2994609

This is also related: “All Users - Files, Shortcuts, RunKey - Windows”

http://bigfix.me/analysis/details/2994610

I am having a hard time figuring out how to get the folder size of each user profile in “c:\users” and displaying that in the console. I am focusing on Windows 7 first, but including Windows XP afterwards would be nice too. We need to know how big user profiles are as part of an AD consolidation migration project.Basically, looking at something like below:

User Profile Size:
User1 1.5GB
User2 10GB
User3 100MB

Any help is greatly appreciated!