Reputation: 309
I search a way to do an automated task with Notepad++ from command line:
Is there any way to do it with some plugin or even with other program ?
Upvotes: 5
Views: 11855
Reputation: 8163
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).
Upvotes: 0
Reputation: 217
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
Upvotes: 3