<?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"
	>
<channel>
	<title>Comments on: Customizing the logging of a Wiindows batch file</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/</link>
	<description></description>
	<pubDate>Sat, 28 Nov 2009 02:35:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Troy Tate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64800</link>
		<dc:creator>Troy Tate</dc:creator>
		<pubDate>Thu, 25 Jun 2009 16:43:16 +0000</pubDate>
		<guid isPermaLink="false">#comment-64800</guid>
		<description>You cannot run individual lines outside the script since there is not any context for some of the calls made in the script. You cannot just cut/paste from the window here due to some issues with this wiki. Unfortunately, you will need to retype the script exactly as shown.</description>
		<content:encoded><![CDATA[<p>You cannot run individual lines outside the script since there is not any context for some of the calls made in the script. You cannot just cut/paste from the window here due to some issues with this wiki. Unfortunately, you will need to retype the script exactly as shown.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MicJ</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64388</link>
		<dc:creator>MicJ</dc:creator>
		<pubDate>Thu, 11 Jun 2009 15:45:16 +0000</pubDate>
		<guid isPermaLink="false">#comment-64388</guid>
		<description>Thanks for this thorough script. It helps but of course, as a basic scripter I have questions. 

In trying to run this on my test workstation - WinXP, I ran your script as is. It did not work so I attempted to run this line by line. When running the line "Call :LogEntry “Starting %0″" from the Windows command line, the following error message appeared: "Invalid attempt to call batch label outside of batch script"

Have I missed something with this?</description>
		<content:encoded><![CDATA[<p>Thanks for this thorough script. It helps but of course, as a basic scripter I have questions. </p>
<p>In trying to run this on my test workstation - WinXP, I ran your script as is. It did not work so I attempted to run this line by line. When running the line &#8220;Call :LogEntry “Starting %0″&#8221; from the Windows command line, the following error message appeared: &#8220;Invalid attempt to call batch label outside of batch script&#8221;</p>
<p>Have I missed something with this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Labnuke99</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64360</link>
		<dc:creator>Labnuke99</dc:creator>
		<pubDate>Wed, 10 Jun 2009 15:36:37 +0000</pubDate>
		<guid isPermaLink="false">#comment-64360</guid>
		<description>Here's a script file I have in my library. Maybe this will do the job for you.

[CODE]
@echo off
::LogEntryDemo.bat
REM Jeffery Hicks  jhicks@sapien.com
REM This script doesn't really do much other than demonstrate
REM how to use the LogEntry routine to create a 
REM log file with a timestamped entry for each line.

REM define path to log file
set myLog=e:templog.txt

REM Delete the logfile if it already exists.
if exist %myLog% del %myLog% &#62;NUL

Echo Working...
REM When sending something to the log routine, enclose the
REM message in quotes.
Call :LogEntry "Starting %0"
Call :LogEntry "Running DIR"
DIR %windir%*.* /s &#62;NUL
Call :LogEntry "Finished DIR"
Call :LogEntry "Sleeping for 30 seconds"
Sleep 30
Call :logEntry "Getting NETSTAT information"
REM Sending results of a NETSTAT command to the log. Notice
REM I'm enclosing the output in quotes. Otherwise, only the
REM first part of the output would be recorded.
for /f "tokens=*" %%t in ('netstat ^&#124;find /i "TCP"') do @Call :LogEntry "%%t"
Call :LogEntry "Finishing logging and opening %myLog%"
REM Display the log
start Notepad %MyLog%
GOTO :EOF

:LogEntry
REM Output will be like: Wed 11/15/2006 05:27 PM "Starting LogEntryDemo.bat" 
for /f "tokens=*" %%i in ('date /t') do @for /f "tokens=*" %%j in ('time /t') do @echo %%i%%j %1 &#62;&#62;%myLog%
GOTO :EOF

:EOF
[/CODE]

This works well to timestamp log entries. 

In the IT trenches? So am I -  read my [A href="http://itknowledgeexchange.techtarget.com/it-trenches"]IT-Trenches blog[/A]</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a script file I have in my library. Maybe this will do the job for you.</p>
<pre>
@echo off
::LogEntryDemo.bat
REM Jeffery Hicks  &nbsp;&lt;a href="mailto:jhicks@sapien.com" title="mailto:jhicks@sapien.com"&gt;jhicks at sapien.com&lt;/a&gt;
REM This script doesn&#8217;t really do much other than demonstrate
REM how to use the LogEntry routine to create a
REM log file with a timestamped entry for each line.

REM define path to log file
set myLog=e:templog.txt

REM Delete the logfile if it already exists.
if exist %myLog% del %myLog% &gt;NUL

Echo Working&#8230;
REM When sending something to the log routine, enclose the
REM message in quotes.
Call :LogEntry &#8220;Starting %0&#8243;
Call :LogEntry &#8220;Running DIR&#8221;
DIR %windir%*.* /s &gt;NUL
Call :LogEntry &#8220;Finished DIR&#8221;
Call :LogEntry &#8220;Sleeping for 30 seconds&#8221;
Sleep 30
Call :logEntry &#8220;Getting NETSTAT information&#8221;
REM Sending results of a NETSTAT command to the log. Notice
REM I&#8217;m enclosing the output in quotes. Otherwise, only the
REM first part of the output would be recorded.
for /f &#8220;tokens=*&#8221; %%t in (&#8217;netstat ^|find /i &#8220;TCP&#8221;&#8216;) do @Call :LogEntry &#8220;%%t&#8221;
Call :LogEntry &#8220;Finishing logging and opening %myLog%&#8221;
REM Display the log
start Notepad %MyLog%
GOTO :EOF

:LogEntry
REM Output will be like: Wed 11/15/2006 05:27 PM &#8220;Starting LogEntryDemo.bat&#8221;
for /f &#8220;tokens=*&#8221; %%i in (&#8217;date /t&#8217;) do @for /f &#8220;tokens=*&#8221; %%j in (&#8217;time /t&#8217;) do @echo %%i%%j %1 &gt;&gt;%myLog%
GOTO :EOF

:EOF
</pre>
<p>This works well to timestamp log entries. </p>
<p>In the IT trenches? So am I -  read my <a href="http://itknowledgeexchange.techtarget.com/it-trenches">IT-Trenches blog</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MicJ</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64356</link>
		<dc:creator>MicJ</dc:creator>
		<pubDate>Wed, 10 Jun 2009 14:36:48 +0000</pubDate>
		<guid isPermaLink="false">#comment-64356</guid>
		<description>Thanks for this info. I would like to eliminate the need for post-parsing of the log file as it may be used for troublshooting in real time. The current batch file is running as a Windows service, running 7 X 24 with many files being moved during our production hours each day. I am looking for a way to make this as clean and as lean as possible at the creation of the log entries appended to the log file throughout the day. Perhaps taking this a step back to simplify things might help me. 

Is there a way to do a simple command to copy a file (using any tool/app) that will create a simple entry in a log file to have a single line item for that file stating [B]Date, Time, Filename, destination directory[/B]. If we can write the log file cleanly, there should be little to no post parsing of the log file needed.</description>
		<content:encoded><![CDATA[<p>Thanks for this info. I would like to eliminate the need for post-parsing of the log file as it may be used for troublshooting in real time. The current batch file is running as a Windows service, running 7 X 24 with many files being moved during our production hours each day. I am looking for a way to make this as clean and as lean as possible at the creation of the log entries appended to the log file throughout the day. Perhaps taking this a step back to simplify things might help me. </p>
<p>Is there a way to do a simple command to copy a file (using any tool/app) that will create a simple entry in a log file to have a single line item for that file stating <b>Date, Time, Filename, destination directory</b>. If we can write the log file cleanly, there should be little to no post parsing of the log file needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pjb0222</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64343</link>
		<dc:creator>Pjb0222</dc:creator>
		<pubDate>Tue, 09 Jun 2009 22:05:25 +0000</pubDate>
		<guid isPermaLink="false">#comment-64343</guid>
		<description>My suggestion is to use Robocopy's built in logging and to leave the job header and job summary enabled.  While there is more information in these items, they also have the information necessary to perform basic troubleshooting should an issue occur.  The job header includes start date and time and the job summary includes completion date and time.  Using the log append allows you to keep prior information.  Or you can roll the log in your script as you require.

C:\Utilities\robocopy C:\TEMP\PageSorting C:\TEMP\PagesSent na*.pdf /R:3 /W:3 /MOV /NP /NS /IS /FP /NDL /LOG+:C:\Temp\TodaysPages.log

Once you have the log, you can strip information out as required with a for loop and the various string utilities (findstr, find, grep).  Example:

FOR /F "tokens=3" %a IN ('findstr /i /r "[a-zA-Z0-9].cmd" C:\Temp\TodaysPages.log') DO @ECHO %a&#62;&#62;C:\Temp\_MySrt.lst

You can also strip out date and time stamps using a for loop and filter them into your results.

You can also use the build in DATE and TIME variables to manually flag you log file.</description>
		<content:encoded><![CDATA[<p>My suggestion is to use Robocopy&#8217;s built in logging and to leave the job header and job summary enabled.  While there is more information in these items, they also have the information necessary to perform basic troubleshooting should an issue occur.  The job header includes start date and time and the job summary includes completion date and time.  Using the log append allows you to keep prior information.  Or you can roll the log in your script as you require.</p>
<p>C:\Utilities\robocopy C:\TEMP\PageSorting C:\TEMP\PagesSent na*.pdf /R:3 /W:3 /MOV /NP /NS /IS /FP /NDL /LOG+:C:\Temp\TodaysPages.log</p>
<p>Once you have the log, you can strip information out as required with a for loop and the various string utilities (findstr, find, grep).  Example:</p>
<p>FOR /F &#8220;tokens=3&#8243; %a IN (&#8217;findstr /i /r &#8220;[a-zA-Z0-9].cmd&#8221; C:\Temp\TodaysPages.log&#8217;) DO @ECHO %a&gt;&gt;C:\Temp\_MySrt.lst</p>
<p>You can also strip out date and time stamps using a for loop and filter them into your results.</p>
<p>You can also use the build in DATE and TIME variables to manually flag you log file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MicJ</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64339</link>
		<dc:creator>MicJ</dc:creator>
		<pubDate>Tue, 09 Jun 2009 20:04:54 +0000</pubDate>
		<guid isPermaLink="false">#comment-64339</guid>
		<description>What I am trying to get to is a line for each item copied/moved broken down as follows:
Date_Time(copied/moved)_filename_DestinationDirectory

My current syntax is
[B]Robocopy:[/B]
C:Utilitiesrobocopy C:TEMPPageSorting C:TEMPPagesSent na*.pdf /R:3 /W:3 /MOV /NP /NS /IS /FP /NDL /NJH /NJS &#62;&#62;TodaysPages.log

[B]XCopy[/B]
date /T &#62;&#62;C:TEMPTodaysPages.log
time /T &#62;&#62;C:TEMPTodaysPages.log
xcopy C:TEMPna*.pdf C:TEMPPagesSent /C /Y &#62;&#62;TodaysPages.log</description>
		<content:encoded><![CDATA[<p>What I am trying to get to is a line for each item copied/moved broken down as follows:<br />
Date_Time(copied/moved)_filename_DestinationDirectory</p>
<p>My current syntax is<br />
<b>Robocopy:</b><br />
C:Utilitiesrobocopy C:TEMPPageSorting C:TEMPPagesSent na*.pdf /R:3 /W:3 /MOV /NP /NS /IS /FP /NDL /NJH /NJS &gt;&gt;TodaysPages.log</p>
<p><b>XCopy</b><br />
date /T &gt;&gt;C:TEMPTodaysPages.log<br />
time /T &gt;&gt;C:TEMPTodaysPages.log<br />
xcopy C:TEMPna*.pdf C:TEMPPagesSent /C /Y &gt;&gt;TodaysPages.log</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pjb0222</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64299</link>
		<dc:creator>Pjb0222</dc:creator>
		<pubDate>Mon, 08 Jun 2009 15:29:33 +0000</pubDate>
		<guid isPermaLink="false">#comment-64299</guid>
		<description>So, using the link button didn't work.

http://blogs.msdn.com/bill/archive/2009/02/13/file.aspx</description>
		<content:encoded><![CDATA[<p>So, using the link button didn&#8217;t work.</p>
<p>&nbsp;&lt;a href="http://blogs.msdn.com/bill/archive/2009/02/13/file.aspx" title="http://blogs.msdn.com/bill/archive/2009/02/13/file.aspx" target="_blank"&gt;http://blogs.msdn.com/bill/archive/2009/&#8230;&lt;/a&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pjb0222</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/customizing-the-logging-of-a-wiindows-batch-file/#comment-64298</link>
		<dc:creator>Pjb0222</dc:creator>
		<pubDate>Mon, 08 Jun 2009 15:28:23 +0000</pubDate>
		<guid isPermaLink="false">#comment-64298</guid>
		<description>Robocopy has a logging switch that includes the command options, list of files copied, status of the copy of each file, start and stop time of the copy session and a summary of the copy results.  You can massage the file name of the log as desired.

Can you give an example of your copy and what a log filename should look like?

Adding the date time into a file name is covered by alot of people, here is one example:

[A href="http://blogs.msdn.com/bill/archive/2009/02/13/file.aspx"]</description>
		<content:encoded><![CDATA[<p>Robocopy has a logging switch that includes the command options, list of files copied, status of the copy of each file, start and stop time of the copy session and a summary of the copy results.  You can massage the file name of the log as desired.</p>
<p>Can you give an example of your copy and what a log filename should look like?</p>
<p>Adding the date time into a file name is covered by alot of people, here is one example:</p>
<p><a href="http://blogs.msdn.com/bill/archive/2009/02/13/file.aspx"></a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- dynamic -->