convert all .txt files in a folder from ibm-850 unicode utf-8
文章推薦指數: 80 %
Option Explicit 'Batch Convert of ibm-850 files to unicode utf-8 with BOM header Dim FS, Folder, File, SourceFile, DestFile Set FS = CreateObject("Scripting ... Batchcharsetconversion-convertall.txtfilesinafolderfromibm-850unicodeutf-8 SampleforScriptUtils.ByteArray.CharSetConvert|Changes|Purchase|Download Examples Thissamplecontainsshortalgorithmtoconvertmorefiles(allfilesinonefolder)fromonecharactersettoanother.Thesampleworksforanycodepage(unicodeutf-8->shift-jis,windows-1250->utf-8,..)andshorterfiles,thefilesareconvertedinmemoryandthereisnogoodideatouseitforfilesover100MB.(SeeCharsetconversionofverylargefiles-2GBandmore).Batchcharsetconversion-convertall.txtfilesinafolderfromibm-850unicodeutf-8 OptionExplicit 'BatchConvertofibm-850filestounicodeutf-8withBOMheader DimFS,Folder,File,SourceFile,DestFile SetFS=CreateObject("Scripting.FileSystemObject") SetFolder=FS.GetFolder(".") 'Processeachfileinfolder ForEachFileInFolder.Files 'Foreach.txtfile IfLCase(Right(File.Name,4))=".txt"Then 'getasourcefilename SourceFile=File.Path 'getadestinationfilename DestFile=Replace(File.Path,".txt","-utf.txt") 'convertthefile FileConvertFile.Path,"ibm850",DestFile,"utf-8" EndIf Next SubFileConvert(SourceFile,SourceCharSet,DestinationFile,DestinationCharSet) 'SaveBOMheaderatthestartofdestinationfile SaveBOMHeaderDestinationFile,"EFBBBF" DimByteArray SetByteArray=CreateObject("ScriptUtils.ByteArray") 'Readthesourcedatafromafile ByteArray.ReadFromSourceFile 'Setcharactersetofthesourcefile ByteArray.CharSet=SourceCharSet 'Convertthedatatoadestinationcharsetandsavethem ByteArray.CharSetConvert(DestinationCharSet).SaveAsDestinationFile,4 EndSub SubSaveBOMHeader(FileName,Header) 'createbytearrayobject DimByteArray SetByteArray=CreateObject("ScriptUtils.ByteArray") 'thebytearraycontainsBOMheader-3bytes. ByteArray.HexString=Header 'SavetheBOMheadertotheFileName ByteArray.SaveAsFileName EndSub OtherlinksfortheBatchcharsetconversion-convertall.txtfilesinafolderfromibm-850unicodeutf-8sample ScriptUtils.ByteArray Workswithsafearraybinarydata-save/restorebinarydatafrom/toadisk,converttoastring/hexstring,codepage/charsetconversions,Base64conversion,etc. ByteArrayisaCOMclassspeciallydesignedtoworkwithMicrosoftWindowsScriptingengines-VBScriptandJScriptinActiveServerPagesorWSHandinCHMorHTAapplications.ItalsoworkswithVBNet,Visualbasic(VBA-VB5,VB6,Word,Excel,Access,…),C#,J#,C++,ASP,ASP.Net,DelphiandwithT-SQLOLEfunctions-seeUseByteArrayobjectarticle.YoucanalsousetheobjectinotherprogrammingenvironmentswithCOMsupport,suchisPowerBuilder. SourcecodeforByteArrayisavailablewithindistributionlicense,pleaseseeLicensepageforASPfileuploadandScriptUtilities. ScriptUtils HugeASPuploadiseasytouse,hi-performanceASPfileuploadcomponentwithprogressbarindicator.Thiscomponentletsyouuploadmultiplefileswithsizeupto4GBtoadiskoradatabasealongwithanotherformfields.HugeASPfileuploadisamostfeatureduploadcomponentonamarketwithcompetitivepriceandagreatperformance.Thesoftwarehasalsoafreeversionofaspuploadwithprogress,calledPureaspupload,writteninplainVBS,withoutcomponents(soyoudonotneedtoinstallanythingonserver).ThisinstallationpackagecontainsalsoScriptUtilitieslibrary.ScriptUtilitiesletsyoucreatehi-performancelogfiles,workswithbinarydata,youcandownloadmultiplefileswithzip/arjcompression,workwithINIfilesandmuchmorewiththeASPutility. ©1996-2011AntoninFoller,MotobitSoftware|About,Contacts|e-mail:[email protected] OtherMotobitlinks: IISTracer,real-timeIISmonitor ASPfileupload-uploadfilestoASP. ActiveX/VBSScriptregistryeditor ActiveXNTUseraccountmanager ExportMDB/DBFfromASP ActiveLogFile Emailexport ActiveX/ASPScriptingDictionaryobject
延伸文章資訊
- 1Notepad++ - Batch convert ANSI GB2312 files to UTF8
Copy the files you want to convert to F:\temp\UTF8. (You may change your path in your script); In...
- 2convert all .txt files in a folder from ibm-850 unicode utf-8
Option Explicit 'Batch Convert of ibm-850 files to unicode utf-8 with BOM header Dim FS, Folder, ...
- 3How To Batch Convert Text Files To UTF-8 Encoding
UTFCast is a small tool for Windows that lets you batch convert all text files to UTF-8 encoding....
- 4How do you batch convert UTF-16 to UTF-8? - PTC Community
So, I have attempted to create a Windows Command Line batch file to open Arbortext Editor and exe...
- 5Batch convert encoding in files - Super User
UTFCast is a Unicode converter that lets you batch convert all text files to UTF encodings with j...