Skip to content

Instantly share code, notes, and snippets.

@lulalala
Created May 1, 2025 02:51
Show Gist options
  • Save lulalala/70ab2a47094a5b70b35e0a00ebdc6705 to your computer and use it in GitHub Desktop.
Save lulalala/70ab2a47094a5b70b35e0a00ebdc6705 to your computer and use it in GitHub Desktop.
update all files under a windows directory, so its created time equals to last updated time
@echo off
setlocal enabledelayedexpansion
:: Set the target directory (change this to your directory)
set "targetDir=F:\2025 RubyKaigi"
echo Processing files in: %targetDir%
echo.
:: Create a temporary PowerShell script
set "tempScript=%TEMP%\update_times.ps1"
echo $files = Get-ChildItem -Path "%targetDir%" -Recurse -File > "%tempScript%"
echo foreach ($file in $files) { >> "%tempScript%"
echo $file.CreationTime = $file.LastWriteTime >> "%tempScript%"
echo Write-Host "Updated: " $file.FullName >> "%tempScript%"
echo } >> "%tempScript%"
:: Run the PowerShell script
powershell -ExecutionPolicy Bypass -File "%tempScript%"
:: Clean up
del "%tempScript%"
echo.
echo Completed.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment