Created
June 6, 2024 06:53
-
-
Save bdonvr/c7b35d999d5878c994ea403119e9bb40 to your computer and use it in GitHub Desktop.
This file contains 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 | |
:: Get today's date in the format MM-DD-YYYY | |
for /f "tokens=2 delims==" %%I in ('"wmic os get localdatetime /value"') do set dt=%%I | |
set year=%dt:~0,4% | |
set month=%dt:~4,2% | |
set day=%dt:~6,2% | |
set today=%month%-%day%-%year% | |
:: Loop through all files in the current directory | |
for %%f in (*.*) do ( | |
:: Check if the filename contains "FDD" | |
if "%%f"=="%%f:FDD=%%f" ( | |
echo File %%f does not contain "FDD" | |
) else ( | |
ren "%%f" "8851 FDD %today%.xlsx" | |
echo Renamed "%%f" to "8851 FDD %today%.xlsx" | |
goto :EOF | |
) | |
:: Check if the filename contains "MP" | |
if "%%f"=="%%f:MP=%%f" ( | |
echo File %%f does not contain "MP" | |
) else ( | |
ren "%%f" "8851 MP %today%.xlsx" | |
echo Renamed "%%f" to "8851 MP %today%.xlsx" | |
goto :EOF | |
) | |
) | |
:EOF | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment