vinnyMS 0 Posted December 15, 2020 i have this script, Func _ANSI2UNICODE($sString = "") Local Const $SF_ANSI = 1 Local Const $SF_UTF8 = 4 Return BinaryToString(StringToBinary($sString, $SF_ANSI), $SF_UTF8) EndFunc ;==>_ANSI2UNICODE i need a version that can target a folder of text files to convert them from ANSI to Unicode Share this post Link to post Share on other sites
vinnyMS 0 Posted December 15, 2020 Please help if possible. I have 2000+ text files to convert. I depend on this Share this post Link to post Share on other sites
Musashi 372 Posted December 15, 2020 (edited) 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 December 16, 2020 by Musashi typo "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
vinnyMS 0 Posted December 16, 2020 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
Aelc 25 Posted December 16, 2020 (edited) $aFileList = _FileListToArrayRec(@ScriptDir, "*.txt", 1,1) doesn't work? Edited December 16, 2020 by Aelc why do i get garbage when i buy garbage bags? Share this post Link to post Share on other sites
vinnyMS 0 Posted December 16, 2020 (edited) i made it work by adding $FLTAR_RECUR Edited December 16, 2020 by vinnyMS Share this post Link to post Share on other sites
Aelc 25 Posted December 16, 2020 (edited) $FLTAR_RECUR actually means 1 but yea i forgot a one Edited December 16, 2020 by Aelc why do i get garbage when i buy garbage bags? Share this post Link to post Share on other sites