【问题标题】:Change lastwritedate using powershell recursively使用powershell递归更改lastwritedate
【发布时间】:2019-11-15 08:08:20
【问题描述】:

我正在尝试使用 MS Powershell 更改文件夹中所有文件和子文件夹中所有文件的 lastwritedate 我已经到了检索所有关注文件的列表

Get-ChildItem -Path . -Recurse -Filter *.* -File

现在我想更改找到文件的日期

(Get-ChildItem -Path . -Recurse -Filter *.* -File) | (Get-Item).lastwritetime=$(Get-Date "10/10/2019 01:05 pm")

但不幸的是它失败了。谁能帮帮我。

【问题讨论】:

    标签: powershell file file-attributes


    【解决方案1】:

    好的,现在我找到了解决方案

    (Get-ChildItem -Path . -Recurse -Filter *.* -File) | foreach {$_.lastwritetime=$(Get-Date "10/10/2019 01:05 pm")}
    

    这个管道输出 gci

    【讨论】:

    • 顺便说一句,-Path .-Filter *.* 都是多余的 - 无论如何,这些都是默认值,并且表达式括号$() 也不需要。
    猜你喜欢
    • 2018-12-03
    • 1970-01-01
    • 2019-09-06
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    • 2014-03-03
    相关资源
    最近更新 更多