1
2
3
4
5
6
7
8
9
10
| Function Format-FileSize()
{
Param ([int]$size)
If ($size -gt 1TB) {[string]::Format("{0:0.00} TB", $size / 1TB)}
ElseIf ($size -gt 1GB) {[string]::Format("{0:0.00} GB", $size / 1GB)}
ElseIf ($size -gt 1MB) {[string]::Format("{0:0.00} MB", $size / 1MB)}
ElseIf ($size -gt 1KB) {[string]::Format("{0:0.00} kB", $size / 1KB)}
ElseIf ($size -gt 0) {[string]::Format("{0:0.00} B", $size)}
Else {""}
}
|
typical usage to find and list all mov
files in directory:
1
| Get-ChildItem -r . *.mov | Select-Object FullName, @{Name="FileSize";Expression={Format-FileSize($_.Length)}}
|