Display the Total Folder Size of Multiple Directories.txt - Notepad

Display the Total Folder Size of Multiple Directories

The below PowerShell command takes a list of UNC paths from a CSV file and generates the total size of each directory (includes all child folders and files - recurse parameter). Ensure that the top cell of the CSV file is named 'name'. The -force parameter includes hidden folders and files. The final line of the script converts the total directory size to Gigabytes (Gb). You can easily change this to Megabytes (Mb).
$dirlist=import-csv C:\users.csv

ForEach ($path in $dirlist) {

$name=$path.name

echo $path >> c:\sizes.txt

$totalsize = (get-childitem $name -recurse -force | measure-object -property length -sum)

"{0:N2}" -f ($totalsize.sum / 1GB) + " GB" >> c:\sizes.txt

}

Back