Comparing text files

  • Thread starter Thread starter Justin Fancy
  • Start date Start date
J

Justin Fancy

Hi,

I have two text files and I need to compare them both, and output the
differences to another text file.

I am comparing a server directory and an IIS Log to see which server
files are of no use to the company anymore (outdated, etc.).

Any suggestions?

Justin
 
Hi,

I have two text files and I need to compare them both, and output the
differences to another text file.

I am comparing a server directory and an IIS Log to see which server
files are of no use to the company anymore (outdated, etc.).

Any suggestions?

Justin


Use the FC command.
See tip 0305 » Windows NT 4.0 has two built in File comparison commands.
in the 'Tips & Tricks' at http://www.jsifaq.com

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
-----Original Message-----
From: Justin Fancy [mailto:[email protected]]
Posted At: Monday, October 23, 2006 4:05 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: Comparing text files
Subject: Comparing text files


Hi,

I have two text files and I need to compare them both, and output the
differences to another text file.

I am comparing a server directory and an IIS Log to see which server
files are of no use to the company anymore (outdated, etc.).

Any suggestions?

Justin

Justin,

It would help if you can provide an example of your IIS logs format.

If speed is not your concern, you could probably go with something as
easy as piping dir output to find/findstr command that will take it as
an argument and will search for string occurences in you IIS logs.
Something like following (untested):

@echo off
setlocal
set iislogsdir="c:\my_iis_logs"
if exist %iislogsdir% (
for /f "delims=" %%i in (www-directory-tree.txt) do (
findstr /b /l "%%i" %iislogsdir%>nul 2>&1 || echo "%%i" is not
fould in logs.
)
)

However, depending of your www dirctory and logs sizes it could take a
long time to complete. Another caveat would be the possible presence of
certain "poison" characters in logs that findstr or batch commands could
not interpret correctly as strings and would threat them as additional.

You could also parce IIS logs first to produce a more compact summary
and then do the same against it. There's a free Microsoft tool that is
good at parsing different kind of logs including IIS called LogParser:
http://www.microsoft.com/technet/scriptcenter/tools/logparser/default.ms
px
 
-----Original Message-----
From: Jerold Schulman [mailto:[email protected]]
Posted At: Monday, October 23, 2006 4:46 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: Comparing text files
Subject: Re: Comparing text files
Hi,

I have two text files and I need to compare them both, and output the
differences to another text file.

I am comparing a server directory and an IIS Log to see which server
files are of no use to the company anymore (outdated, etc.).

Any suggestions?

Justin


Use the FC command.
See tip 0305 > Windows NT 4.0 has two built in File
comparison commands.
in the 'Tips & Tricks' at http://www.jsifaq.com

I'm afraid directory tree and IIS logs are so different in content that
using file-comparsion utilities would not result in an easily
interpreted output. A better definition of what OP actually need would
be IMO "How to determine if a set of text files does not contain
particular set of strings"
 
Damned, I've sent wrong version again.

@echo off
setlocal
set logs="c:\my_iis_logs_dir"
if exist %logs% (
for /f "delims=" %%i in (www-directory-tree.txt) do (
(findstr /l "%%i" %logs%>nul 2>&1
) || (echo "%%i" not found in logs.)
)
) else (echo Cannot find %logs%)
 
Back
Top