I have tried $filesize=(($fileXP).length/1KB)
but this does not retrieve the correct answer.
As for my understanding, it is just dividing the number of characters in files with KB and giving the answer which is wrong.
There has to be some function or attribute to define the size directly and display as we want in KB or MB or GB as required.
To get the file sizes in KB:
Get-ChildItem | % {[int]($_.length / 1kb)}
Or to round up to the nearest KB:
Get-ChildItem | % {[math]::ceiling($_.length / 1kb)}
To get the number characters:
Get-ChildItem | % {(Get-Content $_.FullName).length}
Compare the output and you will see that the length of Get-Childitem
is in KB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With