powershell - Powershell - 使用 dir / GetChildItem 列出修改日期的目录
问题描述
所以目前我可以使用文件夹名称获取我的目录列表
dir -directory -name
而且我也知道我也可以使用递归来列出子目录 谢谢三一
我想在这个列表中创建的是显示这个文件夹的日期修改值。 我查看了文档,我很难找到我假设的答案,如果它在那里,它可能是属性的一部分,但我不确定如何正确格式化它。
我所做的大多数搜索都是关于根据修改日期排除文件,而不是显示日期。
解决方案
你可以用Select-Object
和我喜欢用的Export-Csv
Get-ChildItem C:/temp -directory -recurse | Select-Object FullName, LastWriteTime | Export-Csv -Path list_my_folders.csv -NoTypeInformation
如果您还想提取其他信息,您也可以删除该Select-Object
部分,您将看到所有可以选择的列。
输出:
"FullName","LastWriteTime"
"C:\temp\save","21.11.2019 15:34:27"
"C:\temp\test","12.01.2020 05:13:24"
"C:\temp\test\002custom","14.12.2019 01:17:54"
"C:\temp\test\002normal","14.12.2019 01:31:46"
"C:\temp\test\x","13.01.2020 12:51:05"
"C:\temp\test\002normal\normal","14.12.2019 01:31:53"
"C:\temp\test\x\Neuer Ordner","13.01.2020 12:51:05"
当然你也可以不使用它Export-Csv
:
Get-ChildItem C:/temp -directory -recurse | Select-Object FullName, LastWriteTime > list_my_folders.txt
但输出的格式在大多数情况下更难处理:
FullName LastWriteTime
-------- -------------
C:\temp\save 21.11.2019 15:34:27
C:\temp\test 12.01.2020 05:13:24
C:\temp\test\002custom 14.12.2019 01:17:54
C:\temp\test\002normal 14.12.2019 01:31:46
C:\temp\test\x 13.01.2020 12:51:05
C:\temp\test\002normal\normal 14.12.2019 01:31:53
C:\temp\test\x\Neuer Ordner 13.01.2020 12:51:05
推荐阅读
- django - 如何通过 mixins 继承多个查询集过滤器
- c++ - Boost ASIO - 在接收的同时处理数据
- prometheus - 计算计数器度量范围向量中第一个元素和最后一个元素之间的差异
- css - 报告中的工具提示正在 Oracle APEX IR 中的其他区域之下
- python - Redshift 中的 Python UDF 函数始终返回 NULL 值
- visual-studio - 条件编译符号不起作用
- sql - 如何找到上一年的变化百分比
- javascript - 无法从 office 365 word online 中的 word 表中检索内容控制
- javascript - (Laravel) 预取数据库数据中的实时搜索
- architecture - 如何搭建集成平台