troubleshooting Question

Case insensitive file compare in vbscript

Avatar of justinBoucher
justinBoucherFlag for United States of America asked on
VB ScriptWindows OS
5 Comments2 Solutions567 ViewsLast Modified:
Hi,
  I'm trying to create a file comparison script in vbscript. I have a working model written, but since the two files I will eventually be comparing have different cases in the text, I need to modify my current script to be case insensitive. I can't modify the original text files I'm comparing, or else I would just make the originals all one case in a different script. Can aomeone please help me out. My code is below. Thank you in advance.

Also, here are the contents of the test files:

========
File 1
========
test
test
compare.vbs
test
this

========
File2
========
This
is
a
test
of
the
compare.vbs
script
Dim Diff
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile2 = objFSO.OpenTextFile ("C:\file2.txt", ForReading, True)
Set objOutputFile = objFSO.createtextfile("c:\output_file.txt", ForWriting, True)

Do Until objInputFile2.AtEndOfStream

Diff = false
strNextLine2 = objInputFile2.Readline

Set objInputFile1 = objFSO.OpenTextFile ("C:\file1.txt", ForReading, True)
Do Until objInputFile1.AtEndOfStream
strNextLine1 = objInputFile1.Readline
If (strNextLine2 = strNextLine1) Then
Diff = true
End If
Loop

objInputFile1.Close
If (Diff = false) Then
objOutputFile.WriteLine strNextLine2
End If
Loop


objInputFile2.Close
objOutputFile.Close
Set objInputFile1 = nothing
Set objInputFile2 = nothing
Set objOutputFile = nothing
ASKER CERTIFIED SOLUTION
davidfencik

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros