We help IT Professionals succeed at work.

List of folder and file size

High Priority
154 Views
Last Modified: 2020-01-19
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.
Comment
Watch Question

Consultant
CERTIFIED EXPERT
Commented:
Hi,

You could use:

Dir /S *.*

from within that folder, or specify the path in front of the *.*:

Dir /S "X:\Path\Accounting Users\*.*"


Alan.
Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
CERTIFIED EXPERT
Awarded 2018
Distinguished Expert 2018

Commented:
#$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

Author

Commented:
While these solutions are helpful.
I have looking for a solution that provides a tree view of folder and files. None of these do.
AlanConsultant
CERTIFIED EXPERT

Commented:
Use the TREE command:

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

Alan.

Author

Commented:
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
AlanConsultant
CERTIFIED EXPERT

Commented:
Okay, but that's a long way from what you stipulated in your question.

However, glad you found a solution.

Alan.
Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
CERTIFIED EXPERT
Awarded 2018
Distinguished Expert 2018
Commented:
Well you asked for PS script that shows the folders and size and you want them to have visually accessible with 2 tabs and etc.

Even if it's possible to do it with powershell, because it is, but you're asking a whole development for the solution of your question for free, and honestly I don't think this is going to happen for free.

Good luck with the solution you are searching for.
Probably you should include what you're expecting to have and you can edit your question to be more accurate to what you want.