Extract Data from Text File and Use in Batch

View: New views
3 Messages — Rating Filter:   Alert me  

Extract Data from Text File and Use in Batch

by Ryan Johnson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a text file that looks like this:

PO_NUMBER=RJ12346
EMAIL=email@...

I want to extract both rows to be used in the text file.  How can I do this?  I need to dynamically put in the email address and PO Number in the command line.

c:\sendmail.bat -r %EMAIL% -s "PO %PO_NUMBER% Received" -t "PO %PO_NUMBER% Received"



Re: Extract Data from Text File and Use in Batch

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 05 Jun 2009 21:31:59 -0000, "Ryan Johnson"
<ryan.johnson@...> wrote:

>I have a text file that looks like this:
>
>PO_NUMBER=RJ12346
>EMAIL=email@...
>
>I want to extract both rows to be used in the text file.  How can I do this?  I need to dynamically put in the email address and PO Number in the command line.
>
>c:\sendmail.bat -r %EMAIL% -s "PO %PO_NUMBER% Received" -t "PO %PO_NUMBER% Received"




@echo off
for /f "tokens=1,2 delims==" %%a in ('type "file.txt"') do (
if /i "%%a"=="PO_NUMBER" set "PO_NUMBER=%%b"
if /i "%%a"=="EMAIL" set "EMAIL=%%b"
)

:: the line below is wrapped

call c:\sendmail.bat -r %EMAIL% -s "PO %PO_NUMBER% Received" -t "PO
%PO_NUMBER% Received"

pause



Re: Extract Data from Text File and Use in Batch

by Ryan Johnson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That worked great!  Thanks so much for your help!!!!

--- In batchworld@..., foxidrive <foxidrive@...> wrote:

>
> On Fri, 05 Jun 2009 21:31:59 -0000, "Ryan Johnson"
> <ryan.johnson@...> wrote:
>
> >I have a text file that looks like this:
> >
> >PO_NUMBER=RJ12346
> >EMAIL=email@...
> >
> >I want to extract both rows to be used in the text file.  How can I do this?  I need to dynamically put in the email address and PO Number in the command line.
> >
> >c:\sendmail.bat -r %EMAIL% -s "PO %PO_NUMBER% Received" -t "PO %PO_NUMBER% Received"
>
>
>
>
> @echo off
> for /f "tokens=1,2 delims==" %%a in ('type "file.txt"') do (
> if /i "%%a"=="PO_NUMBER" set "PO_NUMBER=%%b"
> if /i "%%a"=="EMAIL" set "EMAIL=%%b"
> )
>
> :: the line below is wrapped
>
> call c:\sendmail.bat -r %EMAIL% -s "PO %PO_NUMBER% Received" -t "PO
> %PO_NUMBER% Received"
>
> pause
>