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.
延伸文章資訊
- 1純文字檔案的編碼與內文批次轉換:Big5轉UTF-8 / Batch ...
純文字檔案的編碼與內文批次轉換:Big5轉UTF-8 / Batch convert Plain Text Files for Encoding and Content Replacing: B...
- 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, ...
- 3Convert 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...
- 4Batch convert encoding in files - Super User
UTFCast is a Unicode converter that lets you batch convert all text files to UTF encodings with j...
- 5Notepad++ convert to UTF-8 multiple files - Stack Overflow
Need to batch convert a large quantity of text files from ANSI ...