vinnyMS Posted December 15, 2020 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
vinnyMS Posted December 15, 2020 Author Posted December 15, 2020 Please help if possible. I have 2000+ text files to convert. I depend on this
Musashi Posted December 15, 2020 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."
vinnyMS Posted December 16, 2020 Author 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
Aelc Posted December 16, 2020 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?
vinnyMS Posted December 16, 2020 Author Posted December 16, 2020 (edited) i made it work by adding $FLTAR_RECUR Edited December 16, 2020 by vinnyMS
Aelc Posted December 16, 2020 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?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now