<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; любой: замена текста]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8252&amp;type=atom" />
	<updated>2013-04-25T02:39:07Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8252</id>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71652#p71652" />
			<content type="html"><![CDATA[<p>извиняюсь, не то прикрепил</p><p>немного изменен файл. сейчас:<br />в 96 строке <br /></p><div class="codebox"><pre><code>call :zamena &lt;&quot;%file_name%&quot; &gt;&quot;new_%file_name%&quot;</code></pre></div><p>в 274<br /></p><div class="codebox"><pre><code>:zamena
@set @x=0/*!&amp;&amp;@set @x=
...</code></pre></div>]]></content>
			<author>
				<name><![CDATA[arey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30033</uri>
			</author>
			<updated>2013-04-25T02:39:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71652#p71652</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71644#p71644" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>arey пишет:</cite><blockquote><p>во вложении весь батник</p></blockquote></div><p>Нет там его</p>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2013-04-24T10:31:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71644#p71644</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71642#p71642" />
			<content type="html"><![CDATA[<p>не идет одним файлом у меня <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /></p><p>во вложении весь батник<br />обращение к вашему коду идет в 107 строке<br />ваш код на 286 строке начинается</p><p>из-за особенности форума (ограничение по ссылкам) код не могу привести прямо тут. все во вложении</p>]]></content>
			<author>
				<name><![CDATA[arey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30033</uri>
			</author>
			<updated>2013-04-24T08:37:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71642#p71642</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71641#p71641" />
			<content type="html"><![CDATA[<p><strong>arey</strong>, идея очень простая. Вот скелет файла<br /></p><div class="codebox"><pre><code>
@set @x=0/*!&amp;&amp;@set @x=

@echo off

Впишите любой код командного интерпретатора. 

Вызов команд JScript выполняйте следующей командой
Укажите параметры, имена входных и выходных файлов в конце этой строки
%windir%\System32\cscript.exe //nologo //e:javascript &quot;%~dpnx0&quot; 

@goto :eof */

Здесь любой JScript код
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2013-04-24T06:51:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71641#p71641</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71640#p71640" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>badik пишет:</cite><blockquote><p>Скрипт для красивого форматирования с отступами длинных XML indent.js:</p></blockquote></div><p>Спасибо за интересный код с комментариями.</p><p>Мне больше подходит вариант, предложенный <strong>Rumata</strong><br />вот только пока не удалось встроить в основной файл, приходится из одного батника вызывать другой</p><p>если встроить в файл, то выходит ошибка:</p><div class="codebox"><pre><code>d:\script\CMD\XML\new.bat(1, 7) Ошибка компиляции Microsoft JScript: Предполагае
тся наличие &#039;@&#039;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[arey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30033</uri>
			</author>
			<updated>2013-04-24T02:40:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71640#p71640</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71634#p71634" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Rumata пишет:</cite><blockquote><p>С помощью JScript+CMD<br /><strong>z.bat &lt;doc94313.xml &gt;result.xml</strong></p></blockquote></div><p>Благодарю, Ваш пример работает.<br />но мне не удалось встроить это в &quot;рабочий&quot; bat файл.<br />сейчас это выглядит следующим образом:</p><div class="codebox"><pre><code>rem  Узнать количество строк в файле
for /f %%n in ( &#039;more ^&lt; &quot;%file_name%&quot; ^| find /c /v &quot;&quot;&#039; ) do set tail_count=%%n
rem  если в файле 1 строка - расставить переносы
if %tail_count%==1 call z.cmd &lt;%file_name% &gt;new_%file_name%
rem прибираем
del %file_name%
ren new_%file_name% %file_name%</code></pre></div><p>может какое более рациональное решение подскажите ?</p>]]></content>
			<author>
				<name><![CDATA[arey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30033</uri>
			</author>
			<updated>2013-04-23T04:12:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71634#p71634</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71633#p71633" />
			<content type="html"><![CDATA[<p>Скрипт для красивого форматирования с отступами длинных XML indent.js:</p><div class="codebox"><pre><code>// Украсить XML-дерево вставкой отступов. (C) Anton Lapounov 2005
function Indent(node, curIndent, levelIndent)
{
    // Если у узла нет содержимого, ничего не делать
    if (!node.hasChildNodes)
    {
        return;
    }
 
    // Если содержимое включает текстовые узлы, ничего не делать
    for (var child = node.firstChild; child != null; child = child.nextSibling)
    {
        if (child.nodeType == 3 ||  // PCDATA
            child.nodeType == 4)    // CDATA
        {
            break;
        }
    }
 
    if (child != null)
    {
        return;
    }
 
    // Вставить текстовые узлы с отступами между дочерними узлами и обработать их рекурсивно
    var newIndent = curIndent + levelIndent;
    var textNode = node.ownerDocument.createNode(3, &quot;&quot;, &quot;&quot;);
    textNode.text = newIndent;
 
    for (child = node.firstChild; child != null; child = child.nextSibling)
    {
        node.insertBefore(textNode.cloneNode(false), child);
        Indent(child, newIndent, levelIndent);
    }
 
    textNode.text = curIndent;
    node.appendChild(textNode);
}
 
// Пример использования функции Indent:
 
// Загрузить XML-документ из файла XML.xml
var doc = new ActiveXObject(&quot;MSXML2.DomDocument&quot;);
doc.async = false;
 
if (!doc.load(WScript.Arguments(0)))
{
    WScript.Echo(&quot;ERROR: &quot; + doc.parseError.reason);
    WScript.Quit(1);
}
 
// Вставить отступы: перевод строки + 2 пробела на каждый уровень
Indent(doc.documentElement, &quot;\n&quot;, &quot;  &quot;);
 
// Показать документ с отступами
//WScript.Echo(doc.xml);
 
// Сохранить документ с отступами в файл XML.xml
doc.save(WScript.Arguments(0));</code></pre></div><p>Запуск<br />Cscript indent.js&nbsp; file.xml</p>]]></content>
			<author>
				<name><![CDATA[badik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=21834</uri>
			</author>
			<updated>2013-04-23T03:50:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71633#p71633</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71609#p71609" />
			<content type="html"><![CDATA[<p>С помощью команд пакета Unixutils, Cygwin и им подобных<br /></p><div class="codebox"><pre><code>sed &quot;s/&gt;&lt;/&gt;\n&lt;/g&quot; &lt;doc94313.xml &gt;result.xml</code></pre></div><p>С помощью Perl<br /></p><div class="codebox"><pre><code>perl -pe &quot;s/&gt;&lt;/&gt;\n&lt;/g&quot; &lt;doc94313.xml &gt;result.xml</code></pre></div><p>С помощью JScript+CMD<br /><strong>z.bat &lt;doc94313.xml &gt;result.xml</strong><br /></p><div class="codebox"><pre><code>
@set @x=0/*!&amp;&amp;@set @x=
@ %windir%\System32\cscript.exe //nologo //e:javascript &quot;%~dpnx0&quot; %*
@goto :eof */


var stdin = WScript.StdIn;
var stdout = WScript.StdOut;

while ( ! stdin.AtEndOfStream ) {
    var inputLine = stdin.ReadLine();
    var outputLine = inputLine.replace(/&gt;&lt;/g, &#039;&gt;\n&lt;&#039;);
    stdout.WriteLine(outputLine);
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2013-04-22T08:59:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71609#p71609</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71602#p71602" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p>xml лучше, удобнее и <em>надёжнее</em> разбирать при помощи WSH или PoSH.</p></blockquote></div><p>Согласен, тот же XQuery значительно облегчил бы задачу, но к сожалению написать что либо могу лишь средствами командной строки.</p><p>&quot;рабочий&quot; батник выложу чуть позже</p>]]></content>
			<author>
				<name><![CDATA[arey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30033</uri>
			</author>
			<updated>2013-04-22T06:10:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71602#p71602</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71601#p71601" />
			<content type="html"><![CDATA[<p><strong>arey</strong>, xml лучше, удобнее и <em>надёжнее</em> разбирать при помощи WSH или PoSH. Что у Вас в «рабочем бантнике»? Возможно, будет удобнее перевести всё на указанные языки.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2013-04-22T04:09:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71601#p71601</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[любой: замена текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71599#p71599" />
			<content type="html"><![CDATA[<p>Имеется:<br />файлы *.xml в одну строку<br />рабочий бантник которому необходим многострочный файл</p><p>Необходимо:<br />найти закрытие тега и вставить перенос на новую строку, а именно заменить &quot;&gt;&lt;&quot; на &quot;&gt;перенос строки&lt;&quot; (&gt;/n&lt; в Notepad++)</p><br /><p>в бат файле имеется переменная %File_name% с именем обрабатываемого файла. В идеале встроить скрипт в батник.</p><p>Буду рад любому варианту с комментариями (чтоб разобраться в происходящем)</p><p>один из примеров обрабатываемого файла в приложении.</p>]]></content>
			<author>
				<name><![CDATA[arey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30033</uri>
			</author>
			<updated>2013-04-22T02:26:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71599#p71599</id>
		</entry>
</feed>
