沉冰浮水

沉冰浮水

做最终到的事,成为最终成为的人!
github
bilibili
mastodon
zhihu
douban

"Modify the time of files (or folders) to the latest on Windows"

I'm used to managing files by "grouping or sorting by time", and then I need to make the time of confirmed files or folders directly become the latest;

The essence is to directly call PowerShell commands;

Save the following content as a file with the .bat extension, and then drag the file or folder to be modified onto the icon to trigger it;

Both the "creation time" and "last modified time" will be modified at the same time;

The commented line in the middle is used to modify the time of internal items if the executed item is a folder;

@echo off

for %%i in (%*) do (
    echo %~n1
    echo %%i

    @REM powershell.exe -command "if (Test-Path -LiteralPath '%%i' -PathType Container){ls '%%i\*' | foreach-object { $_.LastWriteTime = Get-Date; $_.CreationTime = Get-Date}}"

    powershell.exe -command "Get-ItemProperty -LiteralPath '%%i' | foreach-object {$_.LastWriteTime = Get-Date; $_.CreationTime = Get-Date}"

    echo "-----"
)

@REM pause
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.