<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: Множественная замена слов в файлах .html]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10313&amp;type=atom" />
	<updated>2015-02-20T14:20:02Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10313</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Множественная замена слов в файлах .html]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91735#p91735" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
var FOLDER_PATH = &quot;D:\\MY\\OUT&quot;;
var arrReplaceStrings = [ [&quot;no&quot;,&quot;yes&quot;],[&quot;hi&quot;,&quot;bye&quot;] ];
var reFileMask = /.*.\.html$/i;

var fso = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
var oFolder = fso.GetFolder(FOLDER_PATH);
var fc = new Enumerator(oFolder.files);
var allText = &quot;&quot;, ts;
for (; !fc.atEnd(); fc.moveNext())
{
    var fileName = fc.item().Name;
    if(!reFileMask.test(fileName)) continue;
    ts = fc.item().OpenAsTextStream(1,0);
    allText = ts.ReadAll();
    ts.Close();
    ts = fso.CreateTextFile(fc.item().Path+&quot;_&quot;,true);
    for(var i = 0;i&lt;arrReplaceStrings.length;i++)
    {
        var re = new RegExp(&quot;\\b&quot;+arrReplaceStrings[i][0]+&quot;\\b&quot;,&quot;gi&quot;);
        //Script.Echo(&quot;&quot;+arrReplaceStrings[i][0]);
        allText = allText.replace(re,arrReplaceStrings[i][1]);        
    }
    ts.Write(allText);
    ts.Close();        
}
WScript.Echo(&quot;The End&quot;);
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[olmovc]]></name>
			</author>
			<updated>2015-02-20T14:20:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91735#p91735</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Множественная замена слов в файлах .html]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=90173#p90173" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Yury пишет:</cite><blockquote><p><strong>igor980</strong>, сколько Вы насчитаете слов &quot;<strong>no</strong>&quot; в строке </p><div class="quotebox"><blockquote><p>no no. no! no? &quot;no&quot; no: @no No -no &lt;no&gt; no&amp;yes no not NO no, no; [no] no=yes (no) no- no+yes now no</p></blockquote></div><p><strong>?</strong></p></blockquote></div><div class="quotebox"><cite>igor980 пишет:</cite><blockquote><p>Cлов &quot;no&quot; может быть разное количество в строке,в зависимости от текста в файле</p></blockquote></div><br /><p>&quot;С Вами всё ясно...&quot;</p>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2015-01-08T09:58:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=90173#p90173</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Множественная замена слов в файлах .html]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=90123#p90123" />
			<content type="html"><![CDATA[<p><strong>igor980</strong>, командный язык Windows - далеко не Bash, а потому продвинутые операции с текстом предпочтительней проводить либо с помощью WSH, либо PowerShell, если конечно не устраивают сторонние утилиты вроде порта sed, grep или awk для Windows. В противном случае Вы рискуете попортить нервы не только себе, но и другим.</p>]]></content>
			<author>
				<name><![CDATA[greg zakharov]]></name>
			</author>
			<updated>2015-01-07T10:37:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=90123#p90123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Множественная замена слов в файлах .html]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=90119#p90119" />
			<content type="html"><![CDATA[<p>Cлов &quot;no&quot; может быть разное количество в строке,в зависимости от текста в файле</p>]]></content>
			<author>
				<name><![CDATA[igor980]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32794</uri>
			</author>
			<updated>2015-01-07T08:28:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=90119#p90119</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Множественная замена слов в файлах .html]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=90113#p90113" />
			<content type="html"><![CDATA[<p><strong>igor980</strong>, сколько Вы насчитаете слов &quot;<strong>no</strong>&quot; в строке </p><div class="quotebox"><blockquote><p>no no. no! no? &quot;no&quot; no: @no No -no &lt;no&gt; no&amp;yes no not NO no, no; [no] no=yes (no) no- no+yes now no</p></blockquote></div><p><strong>?</strong></p>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2015-01-06T22:50:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=90113#p90113</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: Множественная замена слов в файлах .html]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=90049#p90049" />
			<content type="html"><![CDATA[<p>Здравствуйте!<br />Помогите пожайлуста сделать множественную замену слов в большом количестве файлов html.</p><p>К примеру в папке C:\Documents and Settings\admin\Рабочий стол\ER2\es-1 лежит 500 html файлов,<br />нужно чтобы cmd файл находил и менял слова(они могут быть с пробелами):<br />no=yes<br />hi=bye<br />today=morrow<br />и так далее.<br />Сам не могу разобраться((<br />Заранее очень благодарен за помощь.</p>]]></content>
			<author>
				<name><![CDATA[igor980]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32794</uri>
			</author>
			<updated>2015-01-06T12:48:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=90049#p90049</id>
		</entry>
</feed>
