首页 > 解决方案 > 将 LastWriteTime 提前 6

问题描述

我有几个同时创建的文件目录,但时钟没有针对时区进行调整。因此,我需要将子目录中文件的 LastWriteTime 增加不同的时间(通常为 6-7 小时),以使文件在创建时保持一致。

这是一个工作示例。

Param(
    [String]$fpath = '6-13',
    [Int32]$addhr = 6
)
$fullpath = 'l:\pictures\europetrips\2011\alex\'
$final = -join($fullpath, $fpath)
$fx = Get-ChildItem -Path $final
foreach ($fz in $fx) {
    $fz.LastWriteTime = $fz.LastWriteTime.AddHours($addhr)
}

这确实会修改LastWriteTime并增加$addhr时间。

一切都很好,除了我在 Windows 资源管理器中查看同一目录时,时间戳没有变化。“日期”不变。“修改日期”已更改。如何修改“日期”?

标签: powershelldatetime

解决方案


推荐阅读