1

I have to update in 650 files.

Sample case Example:

Apple 001
Mango 002
Banana 001
Grapes 003

Expected :

Apple 001|Red
Mango 002 
Banana 001
Grapes 003

Here : Red is the appending text at the end of line.

3
  • What is your question? In notepad++ you can just write |Red behind Apple001 to be honest. Nov 10, 2015 at 7:58
  • Sorry. I have to update similar change in 650 files and it tedious task ahead Nov 10, 2015 at 8:03
  • Sorry for late answer but I guess there is no solution for notepad where you can handle that many files. Instead of this you can use powershell Nov 10, 2015 at 14:17

1 Answer 1

0

I am not sure if you can do this with notepad++ with that many files. But you can use powershell. If you are confident with powershell just use following code, if not feel free to ask me in comments.

script.ps1:

function appendToFirstLine($filepath){
    $file = Get-Content $filepath
    $file[0] += " TEXT TO APPEND"
    $file | Set-Content $filepath
}

cd C:\PATH\TO\FOLDER\OF\TEXT\FILES
Get-ChildItem -Path *.txt | %{ appendToFirstLine $_.FullName }

Explanation: The function appendToFirstLine "gets content" of a file and appends " TEXT TO APPEND" after the first line ($file[0]). Then the script navigates to your folder with the files and uses it on every *.txt file in the folder.

Tip: If you have subfolders use -Recurse flag in the Get-ChildItem-Cmdlet.

In your case " TEXT TO APPEND" would be "|Red", but I highly recommend to copy some files and trying out if you don't want unwished blanks or similar. Furthermore if you execute the script twice, you also have "|Red|Red"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .