Add suffix to the first line of text file using BAT

1

Good people!

I'm editing some F1C game mods, which use text files to store the AI's data for the pilots.

In the first line of each file comes the name of the pilot:

Michael Schumacher

... and I would like to add a suffix at the end of the name, more or less this:

Michael SchumacherRH

Is it possible to do this using only CMD / .bat (if possible using a FOR to do this at once for all files in the folder)?

PS: According to Notepad ++ the files are under UTF-8 encoding (without BOM)

    
asked by anonymous 30.04.2017 / 17:54

2 answers

0

You can start by doing the following. The cmd FOR command can be used for this. You can use the / F switch. This option reads each line of the file. Send the output to another file with the already added suffix. Example:

Test.txt file contents:

  

NAME1

     

NAME2

     

NAME3

     

NAME4

I want to add the letter RH at the end of each line. For this I will use the following:

FOR /F "eol=M" %i IN (test.txt) DO ECHO %iRH >> Teste-com-sufixo.txt

Now the Test-with-suffix.txt file looks like this:

  

NAME1RH

     

NAME2RH

     

NAME3RH

     

NAME4RH

This is a start.

    
06.05.2017 / 20:40
0

Try to see if you can:

in the command line:

for /f "tokens=* delims=^" %i in ('type ".\teste.txt"') do @echo/%iRH>>.\Teste-com-sufixo.txt

in the .bat file:

for /f "tokens=* delims=^" %%i in ('type ".\teste.txt"') do @echo/%%iRH>>.\Teste-com-sufixo.txt
    
19.11.2018 / 16:26