#7166

Yutaka Emura
Keymaster

This is my sample to check if and</p><h2> matches in all HTML files in a folder (searches the folder recursively). You would of course need to modify the root folder, the contents of DoSomething() function, and the file extension to search.</p><pre class="code"><br /> sRootDir = "E:help..."; // root folder<br /> editor.NewFile(); <br /> var docResult = editor.ActiveDocument; <br /> docResult.writeln( "ERRORS Root Folder: " + sRootDir );<br /> <br /> Redraw = false;<br /> var nTotalFiles = EnumerateFolder( sRootDir );<br /> Redraw = true;<br /> <br /> alert( "Finished successfully. Total of " + nTotalFiles + " files processed." );<br /> <br /> <br /> function EnumerateFolder( sFolder )<br /> {<br /> var nTotal = 0;<br /> var fso, f, fc, s;<br /> fso = new ActiveXObject("Scripting.FileSystemObject");<br /> f = fso.GetFolder(sFolder);<br /> fc = new Enumerator(f.files);<br /> for (; !fc.atEnd(); fc.moveNext())<br /> {<br /> sItem = String( fc.item() );<br /> nLen = sItem.length;<br /> if( sItem.indexOf( "_" ) == -1 && sItem.substr( nLen - 4 ) == ".htm" ){ // make sure file or folder does not begin with _ and the file extension is .htm.<br /> DoSomething( sItem );<br /> nTotal++;<br /> }<br /> }<br /> <br /> fc = new Enumerator(f.SubFolders);<br /> s = "";<br /> for (; !fc.atEnd(); fc.moveNext())<br /> {<br /> sItem = String( fc.item() );<br /> nLen = sItem.length;<br /> if( sItem.indexOf( "_" ) == -1 ){ // make sure folder name does not begin with _<br /> nTotal += EnumerateFolder( sItem );<br /> }<br /> }<br /> return nTotal;<br /> }<br /> <br /> function DoSomething( sPath )<br /> {<br /> var y = 0;<br /> editor.OpenFile( sPath, 0, eeOpenAllowNewWindow );<br /> <br /> document.selection.Find( "(?<=<title>).+?(?=</title>)", eeFindNext | eeFindAround | eeFindReplaceRegExp | eeFindReplaceQuiet );<br /> sTitle = document.selection.Text;<br /> if( sTitle.length != 0 ){<br /> y = document.selection.GetTopPointY( eePosLogical );<br /> }<br /> else {<br /> y = document.selection.GetActivePointY( eePosLogical );<br /> }<br /> document.selection.Find( "(?<=<h2>).+?(?=</h2>)", eeFindNext | eeFindAround | eeFindReplaceRegExp | eeFindReplaceQuiet );<br /> sH = document.selection.Text;<br /> document.close();<br /> <br /> if( sH.substr( 0, 3 ) == "Q. " ){<br /> sH = sH.substr( 3 );<br /> }<br /> <br /> if( sTitle.length == 0 || sH.length == 0 || sTitle.indexOf( sH ) == -1 ){<br /> docResult.Activate(); <br /> document.writeln( "" + sPath + "(" + y+1 + "):" );<br /> document.writeln( "t<title> " + sTitle );<br /> document.writeln( "t<h2> " + sH );<br /> document.writeln( "" );<br /> }<br /> }<br /> </pre><p></h2><p>