@ECHO OFF
SETLOCAL
(
FOR /F "tokens=6,8,9,10,11* delims=,? " %%a in (q21921051.txt) do (
set pass=%%a
set month=%%b
set day=%%c
set year=%%d
set sec=%%e
set mac=%%f
CALL :CALC
)
)> text.csv
GOTO :EOF
:calc
if %month:~1,10%==Jan set month=01
if %month:~1,10%==Feb set month=02
if %month:~1,10%==Mar set month=03
if %month:~1,10%==Apr set month=04
if %month:~1,10%==May set month=05
if %month:~1,10%==Jun set month=06
if %month:~1,10%==Jul set month=07
if %month:~1,10%==Aug set month=08
if %month:~1,10%==Sep set month=09
if %month:~1,10%==Oct set month=10
if %month:~1,10%==Nov set month=11
if %month:~1,10%==Dec set month=12
echo "%pass:~9,4%", "%year%-%month%-%day%", "%sec:~,8%", %mac%
GOTO :eof
I used a file with a name q21921051.txtfor my testing.
Almost there. The main problem - delayed expansion- in a block expression (a parenthesised series of statements), parsing of integers and , then . Any one %var%inside the block will be replaced by the value of the variable at the moment the block is analyzed - before the block is executed.
, IF (something) else (somethingelse) %variables% IF - FOR ... DO (block)
: 1) setlocal enabledelayedexpansion !var! %var% var 2) .
, ( ) - >text.csv. > >>, , .
, %month:~1,10%. %var:~m,n%, ,n ; m - count-of-chars-from-begin-of-string, , . ,n = ; = ; missing = m
, %month% "Feb, , , %month:~1% - .