<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT Замена найденой в *.txt строки]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9196&amp;type=atom" />
	<updated>2014-01-31T13:50:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9196</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT Замена найденой в *.txt строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79595#p79595" />
			<content type="html"><![CDATA[<p>JSON в txt, чтобы после заменить строку - однако! Может и парсить тогда на js, чтобы не было головной боли?</p>]]></content>
			<author>
				<name><![CDATA[greg zakharov]]></name>
			</author>
			<updated>2014-01-31T13:50:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79595#p79595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT Замена найденой в *.txt строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79593#p79593" />
			<content type="html"><![CDATA[<p>Для Вашего случая можно так (не обобщая и сохраняя Ваш синтаксис):</p><div class="codebox"><pre><code>@echo on
copy nul 5.out&gt;nul
set replace=      &quot;restore_on_startup&quot;: 4,
for /f &quot;delims=&quot; %%I In (5.txt) do ((
 echo.%%I|&gt;nul find &quot;&quot;&quot;restore_on_startup&quot;&quot;: &quot;&amp;&amp;echo.%replace%||echo.%%I
)&gt;&gt;5.out)
move 5.out 5.txt&gt;nul
pause&gt;nul</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Yury]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30230</uri>
			</author>
			<updated>2014-01-31T13:14:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79593#p79593</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[CMD/BAT Замена найденой в *.txt строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79572#p79572" />
			<content type="html"><![CDATA[<p>Снова требуется помощь опытных форумчан <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Дело в таком вот коде:<br /></p><div class="codebox"><pre><code>@echo on
setlocal EnableDelayedExpansion
For /F &quot;Delims=&quot; %%I In (&#039;find &quot;&quot;&quot;restore_on_startup&quot;&quot;: &quot; 5.txt&#039;) Do (
Set v=&#039;%%~I&#039;)
set context=%v%
set replace=      &quot;restore_on_startup&quot;: 4,
copy nul 5.out

:: Тут начинаются проблемы
for /F &quot;delims=&quot; %%s in (5.txt) do (
set string=%%s

:: Или тута
set result=!string:%context%=%replace%!

echo.!result!&gt;&gt;5.out)
echo.%replace%
echo.%context%
echo.%result%
move 5.out 5.txt
endlocal
pause</code></pre></div><p>Данный скрипт должен через поиск брать из файла строку, содержащую определённую фразу и вставлять вместо неё заранее подготовленную.<br /><span class="bbu"><a href="http://otvet.mail.ru/question/34629706/">Оригинал скрипта</a></span> работает хорошо, особенно, со статичными данными. Пример:<br /></p><div class="codebox"><pre><code>setlocal EnableDelayedExpansion
set context=      &quot;restore_on_startup&quot;: 8,
set replace=      &quot;restore_on_startup&quot;: 4,
copy nul 5.out
for /F &quot;delims=&quot; %%s in (5.txt) do (
 set string=%%s
 set string=!string:%context%=%replace%!
 echo.!string!&gt;&gt;5.out
)
move 5.out 5.txt
pause</code></pre></div><p>Может у кого есть мысли как заставить скрипт работать?</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Доп. материалы</div><div class="fancy_spoiler"><p><a href="http://www.cyberforum.ru/cmd-bat/thread913333.html">http://www.cyberforum.ru/cmd-bat/thread913333.html</a> - Похожая беда<br /><a href="http://ss64.com/nt/syntax-replace.html">http://ss64.com/nt/syntax-replace.html</a> - Документация по&nbsp; set d=%c:b=a%<br /><a href="http://forum.script-coding.com/viewtopic.php?id=7443">http://forum.script-coding.com/viewtopic.php?id=7443</a> - чуть менее похожая тема</p></div></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Файл 5.txt</div><div class="fancy_spoiler"><p><strong>Файл 5.txt</strong><br /></p><div class="codebox"><pre><code>&quot;session&quot;: {
      &quot;restore_on_startup&quot;: 5,
      &quot;restore_on_startup_migrated&quot;: true,
      &quot;startup_migration_time&quot;: &quot;13035403453516971&quot;
   },</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[mljaaa]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31645</uri>
			</author>
			<updated>2014-01-30T23:43:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79572#p79572</id>
		</entry>
</feed>
