Category filter
Scripts to get the size of all items in a specific folder in Windows
Users can now get information about the size of files stored in a specific folder on their Windows 10/11 endpoint devices by deploying scripts via Hexnode UEM console.
Batch script
1 |
dir <enter folder path> /a /s |
Specify the path of the folder and run the script to get a list of items in that folder with their respective file sizes (in bytes). While parameter /a
is used to display every file, including system and hidden files, parameter /s
lists the files in the specified directory and all the sub directories within that directory. The total size of the folder is also returned.
PowerShell script
1 2 3 4 5 6 7 8 9 |
Get-ChildItem -path "<enter folder path>" -File -Recurse | Select-Object FullName | ForEach-Object -Process{New-Object -TypeName PSObject -Property @{Name =$_.FullName;Size = (Get-ChildItem -path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum ).Sum/1kb}} | Select-Object Name, @{Name="Size(KB)";Expression={("{0:N2}" -f($_.Size))}} |
The script returns the name and size of all files (in KB) present in the specified folder.