Avatar of justinBoucher
justinBoucher
Flag for United States of America asked on

Case insensitive file compare in vbscript

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

Open in new window

VB ScriptWindows OS

Avatar of undefined
Last Comment
justinBoucher

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
davidfencik

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Brad Howe

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Brad Howe

LOL, nice
justinBoucher

ASKER
Thanks everyone. I don't really use vbscript that much, so I didn't even know I could use that. Thanks again.
justinBoucher

ASKER
Response time was incredible. only 2 minutes.
Your help has saved me hundreds of hours of internet surfing.
fblack61