I'm creating a batch file that loops through files in my directory, executes a program and renames files based on modified date. I am able to set 'mydate'= to the modified date, but in order to append that date to the file name I need to format it mmddyyyy.
How do I format 'mydate' to mmddyyy? It currently reads mm/dd/yyyy hh:mm AM(PM)
Code:ChDIR C:\Users\finanalyst1433\Desktop\New folder\Output\ SETLOCAL enabledelayedexpansion FOR %%f IN (*.o_g) DO ( CALL C:\RTSimEXE\RTOutput.exe %cd%\%%f Month set mydate=%%~Tf ) FOR %%f IN (*_Mon.csv) DO REN "%%f" "%%~nf_%mydate%%%~xf SET deletestring=_Mon FOR /f "delims==" %%F IN ('dir /b *.csv ^| FIND "%deletestring%"') DO ( SET oldfilename=%%F SET newfilename=!oldfilename:%deletestring%=! REN "!oldfilename!" "!newfilename!" ) EXIT
Bookmarks