I have a batch file that will format the date as YYYYMMDD and store it as a variable. However, when I want to generate a text output file with the date in the filename, it strips everything after the date. Can someone please help? You will notice in my example that you will get an output file with the text, but the filename will be the date and the .txt extension is stripped off.
@echo off
SETLOCAL ENABLEEXTENSIONS
if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
set '%%a'=%%i
set '%%b'=%%j
set '%%c'=%%k))
if %'yy'% LSS 100 set 'yy'=20%'yy'%
set Today=%'yy'%-%'mm'%-%'dd'%
ENDLOCAL & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'%
set mydate=%V_Year%%V_Month%%V_Day%
echo text for output file > %mydate%.txt