powershell - 在 Powershell 中添加返回文件夹大小的函数
问题描述
我正在查询文件夹名称/计数/上次修改的驱动器。但是我还想添加文件夹大小 MB。我已经搜索/尝试了一些选项,但无法让它们工作。
由于某些路径超过 240char,该文件也失败了。是否有解决方法(例如跳过这些文件夹)?
感谢您对我要添加的一行代码的帮助。或对下面的任何更改。非常感谢。
$FOLDER_ROOT = "K:\Docs\"
$OUTPUT_LOCATION = "C:\Users\me\Documents\Powershell_OUT.txt"
Function DirX($directory)
{
Remove-Item $OUTPUT_LOCATION
foreach ($singleDirectory in (Get-ChildItem $directory -Recurse -Directory))
{
$count = Get-ChildItem $singleDirectory.FullName -File | Measure-Object | %{$_.Count}
$summary = $singleDirectory.FullName+"|"+$count+"|"+$singleDirectory.LastAccessTime
Add-Content $OUTPUT_LOCATION $summary
}
}
DirX($FOLDER_ROOT)
解决方案
推荐阅读
- c# - 在后台运行计时器 c# 控制台
- typescript - 单元测试公共方法时内部私有方法未定义 - Jest & TypeScript
- java - 上标中的字符串是 ? 在 HTML 页面中
- google-apps-script - Google 表格 - 根据第 1 行的值隐藏列
- php - 如何在 Laravel 中使用 JSON 对象数组填充 MySQL 数据库?
- laravel - 如何获取当前产品 ID
- git - Helm v3 是否会通过手动添加已弃用的稳定存储库继续工作?
- f# - F# 管道运算符到索引器属性中?
- mysql - MySQL 角色在 Delphi 应用程序中不起作用
- node.js - 我如何在 EJS 中写这个