0

I have a .txt with the following lines:

#307714 Joana Darc Vitoria Campos 2013-07-14 14:25:27 0.0000
#322521 ALINE MADALENA 2013-07-16 08:31:11 0.0000
#323057 Juliana E Ferreira Araujo 2013-07-16 09:35:36 0.0000
#325581 DIOGO 2013-07-16 14:12:12 0.0000
#326718 Matheus 2013-07-16 16:29:51 0.0000

And i have made the following code which will filter # from text above and replace the # in a separate batch!

So the first one to filter the # is as follows:

@echo off
if exist id.txt (
    for /f "tokens=1 delims= " %%a in (id.txt) do (
    findstr /c:"%%a" id.txt >nul && (echo %%a >> trials.txt | echo Filtered: %%a to trials.txt)
    )
) else (
    Echo id.txt não existe.. cria o ficheiro e cola lá  a lista de refs para filtragem!
    pause >nul
)

It will filter the ID's and place them in a text file named trials.txt!

Afterwards i created a separated batch with this code to replace # with a link:

@echo off
setlocal DisableDelayedExpansion
set INTEXTFILE=trials.txt
set OUTTEXTFILE=test_out.txt
set SEARCHTEXT=#
set REPLACETEXT=Give trial:
set OUTPUTLINE=

for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
    SET string=%%A
    setlocal EnableDelayedExpansion
    SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!

    >> %OUTTEXTFILE% echo(!modified!
    endlocal
)
del /q %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%

And the final result after running the two batches will be:

Give trial:307714  
Give trial:322521  
Give trial:323057  
Give trial:325581  
Give trial:326718

Anyone know any way to make these two batch files in a single one?

Thank you :)

zylor
  • 13
  • 1
  • 3

1 Answers1

1
for /f "tokens=1 delims=# " %%a in (id.txt) do (
 >>trials.txt echo(#%%a
 >>test_out.txt echo(Give trial:%%a
)

Don't really know whether you need trials.txt or whether id.txt contains ONLY lines matching #nnn ...

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • id.txt is created by me with the initial list trials is created by the programming with the list of ID's without names and etc :) – zylor Jul 26 '13 at 02:13