Link to home
Start Free TrialLog in
Avatar of Bob Brown
Bob Brown

asked on

List of folder and file size

Can you please find a script or commands that can do the following in "Power Shell or DOS".  
I want to get a list of folder and file size that are within the "Accounting Users" folder.
This is on a Windows 2008 server.
ASKER CERTIFIED SOLUTION
Avatar of Alan
Alan
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
#$Folder="Accounting User Folder" #ex: C:\users\Accounting
$Folder = $env:USERPROFILE
$AllFolders = gci  -path $Folder -Recurse -Depth 3 -Directory

$totalSize=0
foreach($sf in $AllFolders){
    $files =0
    Write-Host "Working with Folder named: $sf"
    $allfils=[System.IO.Directory]::GetFiles($sf.FullName)
    foreach($file in $allfils){
        $fi = [System.IO.FileInfo]$file;
        $files+= $fi.Length / 1mb
    }
    Write-Host "Folder $sf`t size $files mb"
    $totalSize+=$files
}
Write-Host "TotalSize on all Folders is $totalSize mb"

Open in new window

Avatar of Bob Brown
Bob Brown

ASKER

While these solutions are helpful.
I have looking for a solution that provides a tree view of folder and files. None of these do.
Use the TREE command:

https://www.computerhope.com/treehlp.htm

Alan.
Thanks Alan ; However this command and command switches don't display folder size in a Tree View.
If you download the free software, and use it to view for example each users folder in a user directory you will see what I mean.

https://www.jam-software.com. Its called TreeSize
Okay, but that's a long way from what you stipulated in your question.

However, glad you found a solution.

Alan.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial