<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Redirecting Output to a File in Windows Batch Scripts</title>
	<atom:link href="http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/</link>
	<description>Take a byte out of tech!</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:54:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Josh</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-126035</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Wed, 08 Feb 2012 15:54:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-126035</guid>
		<description>Tony, I&#039;m not sure but I don&#039;t think Windows provides that kind of encapsulation of the output.</description>
		<content:encoded><![CDATA[<p>Tony, I&#8217;m not sure but I don&#8217;t think Windows provides that kind of encapsulation of the output.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-126034</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Wed, 08 Feb 2012 15:52:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-126034</guid>
		<description>This is because the plain date command echoes the date in a format that is not file-friendly, such as &quot;Wed 02/08/2012&quot;. When I&#039;m generating a filename based on date, I do something like this:

%date:~10,4%-%date:~4,2%-%date:~7,2%-%date:~0,3%

Which would generate something comparable to this: &quot;2012-02-08-Wed&quot; which is friendly for a filename.

Hope this helps.</description>
		<content:encoded><![CDATA[<p>This is because the plain date command echoes the date in a format that is not file-friendly, such as &#8220;Wed 02/08/2012&#8243;. When I&#8217;m generating a filename based on date, I do something like this:</p>
<p>%date:~10,4%-%date:~4,2%-%date:~7,2%-%date:~0,3%</p>
<p>Which would generate something comparable to this: &#8220;2012-02-08-Wed&#8221; which is friendly for a filename.</p>
<p>Hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-126024</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 08 Feb 2012 12:56:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-126024</guid>
		<description>What I&#039;m trying to do is very similar but I want to use commandline variable to name the file.  What I&#039;m trying to do is something like:

chkdsk h: &gt; %date%.txt

But this doesn&#039;t work

Any Ideas??</description>
		<content:encoded><![CDATA[<p>What I&#8217;m trying to do is very similar but I want to use commandline variable to name the file.  What I&#8217;m trying to do is something like:</p>
<p>chkdsk h: &gt; %date%.txt</p>
<p>But this doesn&#8217;t work</p>
<p>Any Ideas??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-124678</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Thu, 26 Jan 2012 23:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-124678</guid>
		<description>In unix i could begin a script with:
exec &gt;log.out 2&gt;&amp;1
This would redirect all output from the scipt to the log file.  Is there a way to do this in a bat file?  I don&#039;t want to have to put the &gt;log.out 2&gt;&amp;1 after EVERY command in the bat file!</description>
		<content:encoded><![CDATA[<p>In unix i could begin a script with:<br />
exec &gt;log.out 2&gt;&amp;1<br />
This would redirect all output from the scipt to the log file.  Is there a way to do this in a bat file?  I don&#8217;t want to have to put the &gt;log.out 2&gt;&amp;1 after EVERY command in the bat file!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ahmed</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-120958</link>
		<dc:creator>ahmed</dc:creator>
		<pubDate>Wed, 21 Dec 2011 10:07:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-120958</guid>
		<description>i tried this command:
-
echo xcopy /y /e /r /k /h D:\z d:z &gt;D:\log.txt &gt;&gt;copylog.txt
-
result on copylog.txt:
-
xcopy /y /e /r /k /h D:\z d:z
-
i want this for the result on copylog.txt:
-
xcopy /y /e /r /k /h D:\z d:z &gt;D:\log.txt
-

any ideas?</description>
		<content:encoded><![CDATA[<p>i tried this command:<br />
-<br />
echo xcopy /y /e /r /k /h D:\z d:z &gt;D:\log.txt &gt;&gt;copylog.txt<br />
-<br />
result on copylog.txt:<br />
-<br />
xcopy /y /e /r /k /h D:\z d:z<br />
-<br />
i want this for the result on copylog.txt:<br />
-<br />
xcopy /y /e /r /k /h D:\z d:z &gt;D:\log.txt<br />
-</p>
<p>any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seth Wegner</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-120375</link>
		<dc:creator>Seth Wegner</dc:creator>
		<pubDate>Fri, 16 Dec 2011 21:33:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-120375</guid>
		<description>just what I needed and Found after googling as well. Thanks!</description>
		<content:encoded><![CDATA[<p>just what I needed and Found after googling as well. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: please help with linux with redirecting errors and output? &#124; Froggy IT Solutions</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112703</link>
		<dc:creator>please help with linux with redirecting errors and output? &#124; Froggy IT Solutions</dc:creator>
		<pubDate>Thu, 13 Oct 2011 08:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112703</guid>
		<description>[...] if it works for each command, the way you are trying to do it Add your own answer in the comments!Question by CH: please help with linux with redirecting errors and output? I&#039;m trying to redirect th...d nothing has been placed in x3. When I make other errors nothing is put in x3 and they still show [...]</description>
		<content:encoded><![CDATA[<p>[...] if it works for each command, the way you are trying to do it Add your own answer in the comments!Question by CH: please help with linux with redirecting errors and output? I&#039;m trying to redirect th&#8230;d nothing has been placed in x3. When I make other errors nothing is put in x3 and they still show [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112212</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Sun, 09 Oct 2011 03:55:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112212</guid>
		<description>Haha no worries :-)</description>
		<content:encoded><![CDATA[<p>Haha no worries <img src='http://blog.crankybit.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112142</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Sat, 08 Oct 2011 13:06:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112142</guid>
		<description>Scratch that.  Just worked it out - isn&#039;t it always the way that you realise you did something stupid, right after posting it to the world? :)</description>
		<content:encoded><![CDATA[<p>Scratch that.  Just worked it out &#8211; isn&#8217;t it always the way that you realise you did something stupid, right after posting it to the world? <img src='http://blog.crankybit.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112140</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Sat, 08 Oct 2011 13:00:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-112140</guid>
		<description>Hi there.  I seem to  have taken a wrong turn trying to implemend this and have got myself into a real bind.  I created a simple script to run defrag.exe and pipe results to a logfile. So far so good.  I then looked for ways to optionally display the output instead of piping to logfile, and this seemed to work. I changed the script as per below, and it worked but got &quot;2&gt;&amp;1 unexpected at this point&quot; at the end of the script. No biggie, only now when I run *any* script, it churns out output from my defrag script.  Any thoughts on where I went wrong, and how to fix it?  

Many thanks,
Adam

---


@echo off
:: Defrag script

c:
cd \

set output=c:\_scripts\defrag.log
if &quot;%1&quot; == &quot;con&quot; set output=con

echo Defragging your hard drive, please allow to run..
echo. &gt;&gt; %output%
echo --------------------------------------------------------- &gt;&gt; %output%
echo Start defrag on %date% at %time% &gt;&gt; %output%
echo. &gt;&gt; %output%
echo Defragging C: &gt;&gt; %output%
echo. &gt;&gt; %output%
defrag c: -f -v 1&gt;&gt; %output% 2&gt;&amp;1
echo. &gt;&gt; %output%
echo Defragging E: &gt;&gt; %output%
echo. &gt;&gt; %output%
defrag e: -f -v 1&gt;&gt; %output% 2&gt;&amp;1
echo. &gt;&gt; %output%
echo End defrag on %date% at %time% &gt;&gt; %output%
:end</description>
		<content:encoded><![CDATA[<p>Hi there.  I seem to  have taken a wrong turn trying to implemend this and have got myself into a real bind.  I created a simple script to run defrag.exe and pipe results to a logfile. So far so good.  I then looked for ways to optionally display the output instead of piping to logfile, and this seemed to work. I changed the script as per below, and it worked but got &#8220;2&gt;&amp;1 unexpected at this point&#8221; at the end of the script. No biggie, only now when I run *any* script, it churns out output from my defrag script.  Any thoughts on where I went wrong, and how to fix it?  </p>
<p>Many thanks,<br />
Adam</p>
<p>&#8212;</p>
<p>@echo off<br />
:: Defrag script</p>
<p>c:<br />
cd \</p>
<p>set output=c:\_scripts\defrag.log<br />
if &#8220;%1&#8243; == &#8220;con&#8221; set output=con</p>
<p>echo Defragging your hard drive, please allow to run..<br />
echo. &gt;&gt; %output%<br />
echo &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &gt;&gt; %output%<br />
echo Start defrag on %date% at %time% &gt;&gt; %output%<br />
echo. &gt;&gt; %output%<br />
echo Defragging C: &gt;&gt; %output%<br />
echo. &gt;&gt; %output%<br />
defrag c: -f -v 1&gt;&gt; %output% 2&gt;&amp;1<br />
echo. &gt;&gt; %output%<br />
echo Defragging E: &gt;&gt; %output%<br />
echo. &gt;&gt; %output%<br />
defrag e: -f -v 1&gt;&gt; %output% 2&gt;&amp;1<br />
echo. &gt;&gt; %output%<br />
echo End defrag on %date% at %time% &gt;&gt; %output%<br />
:end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-105212</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 11 Aug 2011 19:37:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-105212</guid>
		<description>have tried the above (not http://www.biterscripting.com/) and have an issue, which i suspect is with the application. I am creating a diagnostic script using WINDUMP to capture FTP traffic for testing servers.
I want to get the NIC device so that I can then set a variable to it, then use it to enable WINDUMP logging. I have tried the following command line (hybrid bash script run at CMD):
windump -d &#124; grep Device &gt; \temp\x 2&gt;&amp;1
windump: listening on \Device\NPF_{AAAAAAAA-27B3-0000-A8D8-EA0F6634C14A}

I want to then do DOS for loop, parse the above from \temp\x and get the device name.

the message is put on the screen, but I doubt it is going to STDOUT or STDERR. the \temp\x file is empty. I suspect it is writing to an non standard channel.

any ideas?</description>
		<content:encoded><![CDATA[<p>have tried the above (not <a href="http://www.biterscripting.com/)" rel="nofollow">http://www.biterscripting.com/)</a> and have an issue, which i suspect is with the application. I am creating a diagnostic script using WINDUMP to capture FTP traffic for testing servers.<br />
I want to get the NIC device so that I can then set a variable to it, then use it to enable WINDUMP logging. I have tried the following command line (hybrid bash script run at CMD):<br />
windump -d | grep Device &gt; \temp\x 2&gt;&amp;1<br />
windump: listening on \Device\NPF_{AAAAAAAA-27B3-0000-A8D8-EA0F6634C14A}</p>
<p>I want to then do DOS for loop, parse the above from \temp\x and get the device name.</p>
<p>the message is put on the screen, but I doubt it is going to STDOUT or STDERR. the \temp\x file is empty. I suspect it is writing to an non standard channel.</p>
<p>any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Satish</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-104585</link>
		<dc:creator>Satish</dc:creator>
		<pubDate>Fri, 05 Aug 2011 22:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-104585</guid>
		<description>helpful indeed  , Thanx Folks</description>
		<content:encoded><![CDATA[<p>helpful indeed  , Thanx Folks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-92228</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Tue, 17 May 2011 17:07:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-92228</guid>
		<description>@Guido, right, thanks for pointing him to that. I&#039;m glad this page is turning out to be useful for many people.</description>
		<content:encoded><![CDATA[<p>@Guido, right, thanks for pointing him to that. I&#8217;m glad this page is turning out to be useful for many people.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GuidoDG</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-92158</link>
		<dc:creator>GuidoDG</dc:creator>
		<pubDate>Tue, 17 May 2011 06:19:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-92158</guid>
		<description>Hi Bolt, I had the same question. See the comments starting from 22 April 2009 for the solution. Regards.</description>
		<content:encoded><![CDATA[<p>Hi Bolt, I had the same question. See the comments starting from 22 April 2009 for the solution. Regards.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: z bolt</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-92132</link>
		<dc:creator>z bolt</dc:creator>
		<pubDate>Mon, 16 May 2011 22:54:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-92132</guid>
		<description>It gave me a good start. But, is there a way to echo output to the screen and also to the file?
Basically, my batch file lets prints messages on console and lets user enter Y/N options and does some stuff. I want to capture all the messages and user&#039;s input plus the stdout of commands executed in the batch file. Is it possible?
Thanks for the article!!</description>
		<content:encoded><![CDATA[<p>It gave me a good start. But, is there a way to echo output to the screen and also to the file?<br />
Basically, my batch file lets prints messages on console and lets user enter Y/N options and does some stuff. I want to capture all the messages and user&#8217;s input plus the stdout of commands executed in the batch file. Is it possible?<br />
Thanks for the article!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arun</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-87389</link>
		<dc:creator>arun</dc:creator>
		<pubDate>Tue, 19 Apr 2011 23:18:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-87389</guid>
		<description>Could you give an idea how I could redirect output log to a new file every time I run a batch script
Regards</description>
		<content:encoded><![CDATA[<p>Could you give an idea how I could redirect output log to a new file every time I run a batch script<br />
Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-83935</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Thu, 31 Mar 2011 19:51:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-83935</guid>
		<description>Interesting. Glad it helped!</description>
		<content:encoded><![CDATA[<p>Interesting. Glad it helped!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-83812</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 30 Mar 2011 19:53:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-83812</guid>
		<description>Thank you sooo much for this! Apparently ffprobe (info about mpeg files) only outputs to stderr, was driving me crazy when I couldn&#039;t figure out why I couldn&#039;t direct ouput to a file! :)</description>
		<content:encoded><![CDATA[<p>Thank you sooo much for this! Apparently ffprobe (info about mpeg files) only outputs to stderr, was driving me crazy when I couldn&#8217;t figure out why I couldn&#8217;t direct ouput to a file! <img src='http://blog.crankybit.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vani</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-81615</link>
		<dc:creator>vani</dc:creator>
		<pubDate>Wed, 16 Mar 2011 17:44:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-81615</guid>
		<description>Hey, I&#039;m completely new at this and I was wondering if there is a way that I would be able to redirect the log files in a directories standard output and standard error into and excel spreadsheet in anyway?

Please remember don&#039;t use too advanced of terminology as I just started using shell scripts yesterday for the first time.

Thank you!</description>
		<content:encoded><![CDATA[<p>Hey, I&#8217;m completely new at this and I was wondering if there is a way that I would be able to redirect the log files in a directories standard output and standard error into and excel spreadsheet in anyway?</p>
<p>Please remember don&#8217;t use too advanced of terminology as I just started using shell scripts yesterday for the first time.</p>
<p>Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-80580</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Wed, 09 Mar 2011 17:21:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/#comment-80580</guid>
		<description>Mark, good question. Here&#039;s the answer on this post: &lt;a href=&quot;/redirecting-errors-to-a-file-in-windows-batch-scripts/&quot; rel=&quot;nofollow&quot;&gt;Redirecting Errors to a File in Windows Batch Scripts&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Mark, good question. Here&#8217;s the answer on this post: <a href="/redirecting-errors-to-a-file-in-windows-batch-scripts/" rel="nofollow">Redirecting Errors to a File in Windows Batch Scripts</a>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

