Convert multiple files to UTF-8 encoding with Notepad++
文章推薦指數: 80 %
This file will search all files and folders within a given directory, and use Notepad++ to convert their encoding to UTF-8 without Byte Order Marks. Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. smccutchen/ConvertUTF-8.py CreatedJan4,2017 Star 6 Fork 7 Star Code Revisions 1 Stars 6 Forks 7 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP ConvertmultiplefilestoUTF-8encodingwithNotepad++ Raw ConvertUTF-8.py ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters #2016-2017SoveranceStudios. #ScottMcCutchen #Thisfilewillsearchallfilesandfolderswithinagivendirectory,anduseNotepad++toconverttheirencodingtoUTF-8withoutByteOrderMarks # #ThisfilemustberunusingthePythonScriptpluginfromwithinNotepad++,whichisavailablethroughtheNotepad++PluginManager # #YoumusthavePython2.7installed # #Additionally,thisscriptcanonlyexistandberunfromwithintheNotepad++user'sworkingdirectory,thedefaultofwhichishere: #Notethatselecting"NewScript"fromwithinthePythonScriptpluginwillautomaticallydefaulttothissavelocation #..USERDIRECTORY\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts importos; importsys; fromNppimportnotepad filePathSrc="U:\\UnrealEngine\\Ethereal\\Source\\Ethereal"#Pathtothefolderwithfilestoconvert forroot,dirs,filesinos.walk(filePathSrc): forfninfiles: iffn[-2:]=='.h'orfn[-4:]=='.cpp':#Specifyfiletypes,takingcaretochangethefn[number]tocorrespondtolengthofthefile'sextensionincludingthe. notepad.open(root+"\\"+fn) notepad.runMenuCommand("Encoding","EncodeinANSI") notepad.runMenuCommand("Encoding","ConverttoUTF-8") notepad.save() notepad.close() Copylink LulaSvob commented Sep20,2018 • edited Hereisanimprovedversionthatprintstheactionintheconsoleandalsoaccountsfornon-LatincharacterslikeCyrillic,Japanese,Chineseetc...inthepath #-*-coding:utf-8-*- importos importsys fromNppimportnotepad filePathSrc="D:\\Файлове\\"#Pathtothefolderwithfilestoconvert filePathSrc=filePathSrc.decode('utf-8') os.chdir(filePathSrc) forroot,dirs,filesinos.walk(".",topdown=False): forfninfiles: iffn[-4:]=='.txt': notepad.open(root+"\\"+fn) notepad.runMenuCommand("Encoding","ConverttoUTF-8") notepad.save() console.write('File'+fn+'saved.Closing...\n') notepad.close() Sorry,somethingwentwrong. Copylink Joppest commented Nov15,2019 Thanks!Had~65ksmalltextfileswhereevery1000orsotherewasa0x90charactermessingupmyprocessing! Sorry,somethingwentwrong. Copylink TurtleShroom commented Apr27,2021 Doesthisscriptworkonfoldertrees,withsub-folders? Sorry,somethingwentwrong. Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1convert2utf - PyPI
***Batch mode***: Pass in a directory as the input, and all text files that meets the criteria un...
- 2Notepad++ convert to UTF-8 multiple files - Stack Overflow
Need to batch convert a large quantity of text files from ANSI ...
- 3How to convert 200 target files to UTF 8 in one operation ...
I have a project of about 200 files. The files are encoded in UTF 7. How to convert 200 target fi...
- 4Convert multiple files to UTF-8 encoding with Notepad++
This file will search all files and folders within a given directory, and use Notepad++ to conver...
- 5convert 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, ...