Solved Find and Copy from file

October 4, 2012 at 03:18:53
Specs: Windows XP
Hello,

I'm looking for a way to find a part of text from single line file and copies it with the current username to a separate file. This would run from a batch file at start up.

Location & name of the "read" file: C:\Program Files\TestUse\testuse.sql
string to be found in file above "where ACDID = '12345'"

Location & name of the "output" file: \\server\location\output.txt
output in file username1 - 12345

The output list is "growing", so a new line is started every time.

Anyone an idea?
Thanks in Advance

ABBOV


See More: Find and Copy from file

Report •


#1
October 4, 2012 at 07:24:57
✔ Best Answer
::possible option, please feel free to test.

FIND /i "ACDID" < C:\Program Files\TestUse\testuse.sql >USER1.txt
FOR /F "tokens=2 delims='" %%G IN (USER1.txt) DO set user=%%G
echo username1 - %user% > \\server\location\output.txt

:: mike


Report •

#2
October 4, 2012 at 08:19:34
Mike,

Thanks for your quick response, i think i'm almost there.
If I run the script step bij step in DOS the first line was oké (after including some brackets)

The second line produced an error. translated in english it means "%%G was not expected at this moment"


Here a part of the script:

C:\>pushd \server\location\TestUse\

Z:\server\location\TestUse\>FIND /i "ACDID" < C:\<b>"</b>Program Files<b>"</b>\TestUse\testuse.sql >USER1.txt

Z:\server\location\TestUse>FOR /F "tokens=2 delims='" %%G IN (USER1.txt)
DO set user=%%G
<b>%%G niet verwacht op dit moment.</b>

Z:\server\location\TestUse>


Report •

#3
October 4, 2012 at 09:00:50
If you're manually typing it into the prompt, you'll need to go with %G instead of %%G.

How To Ask Questions The Smart Way


Report •

Related Solutions


Ask Question