Windows 命令行 - 将文件修改时间戳更改为较早的日期时间

标签 windows command-line file-attributes

在 Windows 命令行中,我可以使用以下命令将文件的时间戳更改为当前日期时间:

copy /b filename.ext +,,

我需要的是一种将时间戳设置为之前的日期时间(-1天、-1周等)的方法

这可能吗?

我在 Linux 中通常做的是这样的:

touch -d "$(date -R -r filename) - 2 hours" filename

但我需要这个用于 Windows 命令行,而不是 powershell 或任何其他替代方案。

最佳答案

在 Powershell 中,这有效:

(gci)[1].LastWriteTimeUtc = (New-Object datetime 2013,12,31)

关于Windows 命令行 - 将文件修改时间戳更改为较早的日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49939185/

相关文章:

c++ - 如何设置 Vim 以使用 Visual Studio 2010 的 C++ 编译器进行编译?

windows - gsutil rsync 排除模式不适用于 Windows Powershell

c# - 使用多个进程/线程/任务从多个源收集数据

windows - 仅在命令行中列出具有路径和文件大小的文件

file - Matlab 的 "fileattrib"函数中可能存在错误。解决方法?

windows - 如何在 Windows 上模拟 "wrapper script"?

java - 我如何让 TestNG 在特定组中运行测试(从命令行)?

linux - 在 screen 中启动脚本

objective-c - 文件属性是否包含毫秒? Objective-C

windows - 如何在 Python/Go/C/Batch 中获取 Windows 中的扩展文件属性?