Add suffix to first line text file using BAT

Asked

Viewed 1,285 times

1

Good staff!

I’m editing some F1C game mods, which uses text files to store pilots' AI data.

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

Michael Schumacher

... and I’d like to add a suffix at the end of the name, more or less that:

Michael SchumacherRH

You can 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)

1 answer

1

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

Contents of the Test.txt file:

NOME1

NOME2

NOME3

NOME4

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 file Test-with-suffix.txt will look like this:

NOME1RH

NOME2RH

NOME3RH

NOME4RH

This is a start.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.