Update file or folder Date Modified

前端 未结 4 1674
无人共我
无人共我 2021-01-03 09:14

I need to update the \"Date Modified\" property of files and folders as they are copied from one location to the other so that \"Date Modified\" = Current System Time. I ha

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 09:45

    You could use powershell, which I believe is already installed on Windows 7 by default. Add this line to your batch file to run a powershell command that updates the timestamp on all files named Abandoned_Wire*.*:

    powershell.exe -command "ls 'folder\Abandoned_Wire\*.*' | foreach-object { $_.LastWriteTime = Get-Date }"
    

    What that line is doing is simply:

    -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)

提交回复
热议问题