0

I have a directory with over 100 text files.

How can I append the word "END" at the end of every file within that directory?

Kimo
  • 179
  • 2
  • 12
  • Do you want to rename every file in a directory?. or add END inside the file? – pz64_ Mar 22 '19 at 10:31
  • 2
    That is not a job for NOtepad++, you have to write a script in your favorite scripting language. Try something and come back if you have some difficulties. – Toto Mar 22 '19 at 10:33
  • I don't need to rename anything, just add "END" inside every file. – Kimo Mar 22 '19 at 10:35
  • @Toto I was hoping that there was a special character that would match the end of a file, then it could work if we did a replace of that character on every file of that folder. – Kimo Mar 22 '19 at 10:38
  • `Find what: \z` & `Replace with: END` does the job for 1 file (`\z` means end of file). To modify 100+ files you can do that 100+ times or, simpler, write a script. – Toto Mar 22 '19 at 10:42
  • @Toto Works like a charm! You can do it for 100 files in the blink of an eye by using the "Replace in Files" feature. – Kimo Mar 22 '19 at 10:51

2 Answers2

1

Follow these steps.

  1. Backup your files.
  2. Go to the relevant directory.
  3. Open CMD from that directory.
  4. Run this command.

for %f in (*.txt) do echo END >> %f

Screenshot

Note:
If your text file encoding is not ANSI, then the result might be different from what you want.

ANSI > This is a test.END
Unicode > This is a test.久⁄਍
Unicode big endian > This is a test.䕎䐠ഊ
UTF-8 > This is a test.END

You might want to check these links too...

DxTx
  • 2,469
  • 2
  • 15
  • 28
0

PowerShell option:

 "END" | Add-Content -path *.txt

Add-Content will append the pipeline input to all files matching its parameters (there are other options to include/exclude lists of wildcard patterns).

Richard
  • 100,436
  • 21
  • 189
  • 251