批量格式化文件时间
一、常用命令
-
-command: tells powershell to run the following command and return immediately
-
ls: list all matching files at the path specified
-
foreach-object: run the following block on each file that ls found
-
$_.LastWriteTime = Get-Date: for each file, set the LastWriteTime to the value returned by Get-Date (today’s date and time)
-
$_.CreationTime = Get-Date: for each file, set the CreationTime to the value returned by Get-Date (today’s date and time)
二、递归格式化
@ECHO OFF
powershell.exe -command "Get-Childitem -path 'D:/tmp' -Recurse | foreach-object { $_.LastWriteTime = '05/01/2019 00:00:00'; $_.CreationTime = '05/01/2019 00:00:00' }"
PAUSE