Jump to content
vinnyMS

batch convert text files from ANSI to Unicode

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."

Share this post


Link to post
Share on other sites

thank you so much

how do i make it work on all sub folders with "_FileListToArrayRec"

it doesn't seem to work,

 

i also removed the "converted" folder to replace all files and to let them where they're located originally

Share this post


Link to post
Share on other sites

$FLTAR_RECUR actually means 1 :P 

but yea i forgot a one :mad2:

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...