// This macro converts the encoding of all files (of specified file extension) in the specified folder to a specified encoding. // Warning: this macro cannot undo the changes. Please make backup of your files before you run! // // folder to search // remember to escape \ with another \. sFolder = "C:\\Test"; // file extension (must begin with a period (.) ) sExt = ".txt"; // source file encoding // available encodings can be found at http://www.emeditor.com/help/macro/const/const_encoding.htm nSrcEncoding = eeEncodingSystemDefault; // destination file encoding // available encodings can be found at http://www.emeditor.com/help/macro/const/const_encoding.htm nDestEncoding = eeEncodingUTF8; // destination file Unicode Signature (BOM), true or false. bUnicodeSignature = false; if( sFolder != "" ){ fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFolder(sFolder); fc = new Enumerator(f.files); sItem = ""; for (; !fc.atEnd(); fc.moveNext()) { n = fc.item().name.lastIndexOf("."); if( n != -1 ){ if( fc.item().name.slice( n ) == sExt ){ sPath = sFolder + "\\" + fc.item().name; try { editor.OpenFile( sPath, nSrcEncoding, eeOpenDetectUnicode ); } catch(e){ break; } document.Encoding = nDestEncoding; document.UnicodeSignature = bUnicodeSignature; document.Save( sPath ); } } } }