1.

Solve : Help with batch...?

Answer»

hello, very nice community

i have made the following batch FILE

Code: [Select]ECHO off
cls
:start
set /p input=Write What are you search for :
findstr /n /i /c:%input% * /all > %input%_bY_Chrisad.txt
goto end
:end

What this do :

ask from user to insert a string
Search all text files in the directory for some string that user want.
Collect the lines of texts that contain the string
and create a new text file named searched_string_by_Chrisad.txt

Works Gr8!

but i need to do some changes and i need help.

i want same procedure but i want the searched sting not entered by user but  to be at a text file stings.txt like that :

sting1
sting2
sting3

.......

and search for the fist (sting1) all text files --->  and create as results  sting1.txt

after

search for the second (sting2) all text files ---> and create as results string2.txt

after

search for the THIRD (sting3) all text files ---> and create as results string3.txt

hope to be understandable

thanks for any help
My batch is a bit rusty, but you can do this using FOR

ECHO off
cls
:start
set /p input=Write What are you search for :
findstr /n /i /c:%input% * /all > %input%_bY_Chrisad.txt
goto end
:end

for /f "tokens=1*" %%a in ('type INPUTFILE.TXT') do findstr /n /i /c:%%a%%b * /all > %input%_bY_Chrisad.txtthanks for reply,

i try this :

Code: [Select]
ECHO off
cls
:start
for /f "tokens=1*" %%a in ('type INPUTFILE.TXT') do findstr /n /i /c:%%a%%b * /all > results.txt
goto end
:end


but :

if INPUTFILE.TXT have 5 lines

text1
text2
text3
text4
text5

i take the message :

findstr : CANNOT OPEN */ALL
findstr : CANNOT OPEN */ALL
findstr : CANNOT OPEN */ALL
findstr : CANNOT OPEN */ALL

Four times and i take results only for the last line (text5)

the same thing HAPPEN if  the INPUTFILE.TXT have 2-3-5 or any other number of values only take the last one...

any other help ?I have 1 txt file X having FIELDS a, b, c and I want to make Y file which would only contain b field from X file with the help of batch file. Kindly help how I can make it? ('type INPUTFILE.TXT')


I think the problem is you're not including the path..

('type C:\folder\INPUTFILE.TXT')

Or maybe change directory



Discussion

No Comment Found