[英]Powershell script to get csv file with file name and file size for a folder
I have folder and there are sub folders in it.我有文件夹,里面有子文件夹。 I need file name and size in the csv for all the files in the folder.
对于文件夹中的所有文件,我需要 csv 中的文件名和大小。
This code should work for you这段代码应该适合你
$Directory = "C:\path to directory"
Get-ChildItem -Path $Directory -Recurse -Force | ForEach {
[PSCustomObject]@{
Name = $_.Name
Size = "$([int]($_.length / 1mb)) MB"
}
} | Export-Csv -Path "./temp.csv" -NoTypeInformation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.