|
Answer» Could someone help me figure this out? I am trying to take the below text string and find in it 25701-Tract then copy that text to the end of the same line separating by comma, then taking the second date which is at the end of the text line JUN 23 2008 12:05 PM and CONVERT it to 06-23-08 and then move it also to the end of the text line after 25701-Tract separating by comma.
Skip the first date. Question - Is there a way to use a wildcard in a date variable? Example: If = JUN (wildcard) 2008 rename it to 06-23-08 because the dates are always different.
Example Text string: 070000150,Request,42219,,XXXXX,XX,,XXXXXX,XX,XXXXX,,,,,025701-Tract 46-X-XXXXXXXX XXX- XXXXX X-EAST-,JUN 15 2008 02:45 PM, Denied ,JUN 23 2008 12:05 PM, Temp
Thanks for your help. I've nearly got what you need, the first part works fine you can add the Tract thingy to the end of the text file it's just i can't get SET to work... :S
Code: [Select]for /f "tokens=1-15 delims=,-" %%A in ('type test.txt') do ( echo , %%I %%J >>test.txt set num=%%O )
for /f "tokens=1-3 delims= " ("%num%") do ( set mon=%%1 if %mon% == JAN set month == 01 ELSE if %mon% == FEB set month == 02 else if %mon% == MAR set month == 03 else if %mon% == APR set month == 04 else if %mon% == MAY set month == 05 else if %mon% == JUN set month == 06 else if %mon% == JUL set month == 07 else if %mon% == AUG set month == 08 else if %mon% == SEP set month == 09 else if %mon% == OCT set month == 10 else if %mon% == NOV set month == 11 else if %mon% == DEC set month == 12 else ) set yy=%%3 set %yy:~2,2%
echo , %mon% %%2 %yy%>>test.txt
pausescrap the last one this should work:
Code: [Select]echo off setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=1-21 delims=,- " %%A in ('type %CD%\test.txt') do ( set tract= %%I %%J set mon=%%R set yy=%%T set day=%%S )
rem R = months S = day T = year
if !mon!==JAN set month=01 if !mon!==FEB set month=02 if !mon!==MAR set month=03 if !mon!==APR set month=04 if !mon!==MAY set month=05 if !mon!==JUN set month=06 if !mon!==JUL set month=07 if !mon!==AUG set month=08 if !mon!==SEP set month=09 if !mon!==OCT set month=10 if !mon!==NOV set month=11 if !mon!==DEC set month=12
set yy=!yy:~2,2! echo , !tract!, !mon! !day! !yy! >> test.txt thanks go to Dias de Verano
FBYou Guys did Great! Thanks for the help...
Ken
|