Jump to content

File compare script


shay
 Share

Recommended Posts

Hi

i use this script to compare 2 INI files,

i want to add an output text file so any actual change will be written to file

and display this file if file compare fail.

$File1 = FileGetShortName("C:\test.ini")
$File2 = FileGetShortName("C:\test1.ini")
$RET = RunWait(@ComSpec & " /c " & 'FC /B ' & $File1 & " " & $File2, @TempDir, @SW_HIDE)
If Not $RET Then
    MsgBox(64, "Match", "File compare matched")
Else
    MsgBox(16, "Error", "File compare did not match")

EndIf

i know the command line (dos)

fc c:\test.ini c:\test1.ini /d /a /l /n /c >tmp

the">tmp" will output the result to file but i don't know where to add it in the code.

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

Hi,

$RET = RunWait(@ComSpec & " /c " & 'FC /B ' & $File1 & " " & $File2 & " >tmp" , @TempDir, @SW_HIDE)

This will be an binary compare. ini files are in normal case ascii files, so you should also try

$RET = RunWait(@ComSpec & " /c " & 'FC /L ' & $File1 & " " & $File2 & " >tmp" , @TempDir, @SW_HIDE)

The output will be stored in a file named tmp in the @TemDir directory.

you have to interpret the output in the tmp file, because fc will give no return value

look help for _FileReadto Array and StringInStr. This will give you a guess.

;-))

Stefan

Not elegant:

#Include <File.au3>

Dim $arecords, $i, $find
$File1 = FileGetShortName("C:\test.ini")
$File2 = FileGetShortName("C:\test1.ini")
RunWait(@ComSpec & " /c " & 'FC /B ' & $File1 & " " & $File2 & ">tmp", @TempDir, @SW_HIDE)
If Not _FileReadToArray(@TempDir & "\tmp",$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf

For $i = 1 To UBound ($arecords) -1
    ;change "FC: No differences found" to proper output of fc. i have only german system, so idon't know the exactly term
    If StringInStr ($arecords [$i], "FC: No differences found") = 0 Then
        $find = 0
        ContinueLoop
    Else
        $find = 1
        ExitLoop
    EndIf
Next
If $find = 1 Then
    MsgBox(64, "Match", "File compare matched")
Else
    MsgBox(16, "Error", "File compare did not match")
EndIf
Edited by 99ojo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...