How can I batch-convert files in a directory for their encoding (e.g. ANSI->UTF-8) with a command or tool?
For single files an editor helps, but how to do the mass files job?
|
|
Cygwin or GnuWin32 provide Unix tools like Convert from one (
Or in a find-all-and-conquer form:
Alternatively:
This question has been asked many times on this site, so here's some additional information about "ANSI". In an answer to a related question, CesarB mentions:
The page he links to gives this historical tidbit (quoted from a Microsoft PDF) on the origins of CP 1252 and ISO-8859-1, another oft-used encoding:
|
||||
|
|
|
with powershell you can do something like this:
while ENC is something like unicode, ascii, utf8, utf32. checkout 'help out-file'. to convert all the *.txt files in a directory to utf8 do something like this:
which creates a converted version of each .txt file in DIR2. EDIT: To replace the files in all subdirectories use:
|
||||
|
|
|
The Wikipedia page on newlines has a section on conversion utilities. This seems your best bet for a conversion using only tools Windows ships with:
|
|||||
|
|
UTFCast is a Unicode converter for Windows which supports batch mode. I'm using the paid version and am quite comfortable with it.
|
||||
|
|
|
There is How do I convert between Unix and Windows text files? has some more tricks |
|||
|
|