【问题标题】:displaying frequency distribution of all files recursively that were modified in the last 45 days递归显示最近 45 天内修改的所有文件的频率分布
【发布时间】:2013-01-30 21:57:39
【问题描述】:

我正在尝试将这两个脚本放在一起:

这个列出了所有目录下的所有文件:

dir -recurse | group-object Extension -noelement

这个列出了在某个日期之后修改的所有文件:

get-childitem –recurse | where-object {$_.lastwritetime -gt “1/13/2008”}

我的问题是第二个脚本为每个目录输出一个标题:

Mode                LastWriteTime     Length Name                                                                      
----                -------------     ------ ----                                                                      
d----        12/10/2012  11:21 AM            BUDGET                                                                    
d----        12/21/2012  12:38 PM            SPEND DOWN                                                                


    Directory: \\file\property\vt\Environmental Services\BUDGET\SPEND DOWN


Mode                LastWriteTime     Length Name                                                                      
----                -------------     ------ ----                                                                      
d----        12/13/2012  12:32 PM            2012                                                                      
d----         1/29/2013   9:50 AM            2013                                                                      


    Directory: \\le\property\vt\Environmental Services\BUDGET\SPEND DOWN\2012

我试着像这样把它们放在一起:

dir -recurse | group-object Extension -noelement | where-object {$_.lastwritetime -gt (Get-date).AddDays($somenumber)}

但这并没有产生任何结果。

如何在所有目录中递归列出某一天以来所有不同类型文件的计数?

这是我的预期输出:

4352    .JPG
2352    .doc
2135    .pdf
1811    .xls
1472    
857 .pub
732 .xlsx
565 .docx
66  .rtf
64  .lnk
63  .ppt
61  .url
41  .png
38  .xml
28  .htm
27  .msg

【问题讨论】:

    标签: windows powershell batch-file


    【解决方案1】:

    dirgci 都是 Get-ChildItem cmdLet 的别名。分组前过滤:

    gci -Recurse| where {$_.LastWriteTime -gt (Get-Date).AddDays(-45)}| group Extension -NoElement
    

    【讨论】:

    猜你喜欢
    • 2014-05-29
    • 2016-07-03
    • 1970-01-01
    • 2020-09-12
    • 2013-09-30
    • 1970-01-01
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多