5

I search a way to do an automated task with Notepad++ from command line:

  1. Open file
  2. Change encoding to UTF-8
  3. Save file

Is there any way to do it with some plugin or even with other program ?

2 Answers 2

3

Why do you want to use Notepad++ for that task? Which OS are you using? Notepad++ got a Plugin-manager where you can install the Python Script plugin.

http://pw999.wordpress.com/2013/08/19/mass-convert-a-project-to-utf-8-using-notepad/

But if you want to convert files to UTF8 you can do that way easier with PowerShell on Windows or command line on Linux.

For Windows Power-Shell:

$yourfile = "C:\path\to\your\file.txt"
get-content -path $yourfile | out-file $yourfile -encoding utf8

For Linux use (e.g.) iconv:

iconv -f ISO-8859-15 -t UTF-8 source.txt > new-file.txt
Sign up to request clarification or add additional context in comments.

3 Comments

Powershell is OK as long as you want to your UTF8 files to contain a BOM, this is the default and not easily worked around.
@Broco the output file is empty when I run this script. Any idea why?
@Josh I think I find out why and a solution. Check my answer (if you still care about this)
0

Windows Powershell script to change all the files in the current folder (and in all subfolders):

foreach ($file in @(Get-ChildItem *.* -File -Recurse)) {
    $content = get-content $file
    out-file -filepath $file -inputobject $content -encoding utf8
}

If you want to change only specific files just change the *.* (in the first line).


Note: I tried the pipe (|) approach in Broco's answer and was not working (I got empty output files as Josh commented). I think is because we probably cannot read and write directly from and to the same file (while in my approach I put the content into a memory variable).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.