Jump to content

batch convert text files from ANSI to Unicode


vinnyMS
 Share

Recommended Posts

Try :

#include <File.au3>
Global $aFileList, $sFileRead, $hFileOpen
$aFileList = _FileListToArray(@ScriptDir, "*.txt", $FLTA_FILES)
For $i = 1 To $aFileList[0]
    $sFileRead = FileRead(@ScriptDir & "\" & $aFileList[$i])
    ConsoleWrite($i & ": convert file " & $aFileList[$i] & @CRLF)
    $hFileOpen = FileOpen(@ScriptDir & "\converted\" & $aFileList[$i], BitOR($FO_OVERWRITE, $FO_CREATEPATH, $FO_UTF8_NOBOM))
    FileWrite($hFileOpen, $sFileRead)
    FileClose($hFileOpen)
Next

The original text files (ANSI) in the @ScriptDir will be converted and stored in the subdirectory \converted.

Edited by Musashi
typo

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...