Created
May 1, 2025 02:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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