Re: Comparing Two Files



"Crowey" <john.crowe@xxxxxxxxxxxxx> wrote in message
news:1137032982.415152.207820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[snip]

> Sorry mate, that's where my vast inexperience is showing - I don't
> know; I pinched that from somewhere (as is the entire script - pinched
> a bit here, borrowed a bit there ...) to see if it helps; but it turns
> out that it doesn't. If I comment out those first 6 lines I still get
> the exact same error ...


Will this help? Watch for word-wrap.

Option Explicit
'*
'* Declare Constants
'*
Const cFolders = "C:\DUMMY\TESTPROFILES\FullFolderList_2006111.log"
Const cUsers = "C:\DUMMY\TESTPROFILES\FullUserList_2006111.log"
Const ForReading = 1
'*
'* Delare Variables
'*
Dim arrFolders, strFolders, strFolder
Dim arrUsers, strUsers, strUser
Dim vContainer1
'*
'* Declare Dictionary
'*
Dim dicFolders
Set dicFolders = CreateObject("Scripting.Dictionary")
dicFolders.CompareMode = vbTextCompare
Dim dicUsers
Set dicUsers = CreateObject("Scripting.Dictionary")
dicUsers.CompareMode = vbTextCompare
'*
'* Declare FileSystemObject
'*
Dim objFSO
'Set objFSO = CreateObject("Scripting.FileSystemObject","HW006607")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*
'* Folders
'*
Dim objFolders
Set objFolders = objFSO.OpenTextFile(cFolders, ForReading)
strFolders = objFolders.ReadAll
Set objFolders = Nothing
arrFolders = Split(strFolders, vbCrLf)
For Each strFolder In arrFolders
'WScript.Echo strFolder
dicFolders.Add strFolder, ""
Next
'*
'* Users
'*
Dim objUsers
Set objUsers = objFSO.OpenTextFile(cUsers, ForReading)
strUsers = objUsers.ReadAll
Set objUsers = Nothing
arrUsers = Split(strUsers, vbCrLf)
For Each strUser In arrUsers
'WScript.Echo strUser
dicUsers.Add strUser, ""
Next
'*
'* Compare Folders to Users
'*
For Each strFolder In arrFolders
If Not dicUsers.Exists(strFolder) Then
WScript.Echo strFolder & " is in arrFolders but not in arrUsers"
' Else ' Item exists so lets check the size.
'? strUser is not set in this For loop!
' If dicUsers.Item(strUser) <> dicFolders.Item(strFolder) Then
' WScript.Echo "Key item " & vContainer1 & " is different"
' End If
End If
Next
'*
'* Compare Users to Folders
'*
For Each strUser In arrUsers
If Not dicFolders.Exists(strUser) Then
WScript.Echo strUser & " is in arrUsers but not in arrFolders"
End If
Next
'*
'* Destroy Objects
'*
Set objFSO = Nothing
Set dicFolders = Nothing
Set dicUsers = Nothing
'*
'* Finished
'*
WScript.Echo "Finished!"


I tested it with files that contained:
1
3
5
and
1
2
3

It reported that
5 is in arrFolders but not arrUsers
and
2 is in arrUsers but not arrFolders

I have no idea what the commented out part is supposed to do.


.



Relevant Pages

  • Re: FileSearch Object. Strange result with Wildcards
    ... FileSearch Object giving different results on win98 and XP. ... Dim varfile As Variant ... Dim aFoldersAs Variant, strFolder As String, _ ...
    (comp.databases.ms-access)
  • Re: directory listing
    ... Dim strFile As String ... Dim strFolder As String ... Dim strPF As String 'Previous Folder ... Dim LineNum As Long ...
    (microsoft.public.excel.programming)
  • Disable Inactive users
    ... Dim objRootDSE, strConfig, objConnection, objCommand, strQuery ... Dim strDN, dtmDate, objDate, lngDate, objList, strUser ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Reading From txt file - newbie
    ... I have a script that remove's the Profile, Home and Terminal Services ... dim strUser, strDomain, strUserDN ... strUser = InputBox ... On Error GoTo 0 ...
    (microsoft.public.scripting.vbscript)
  • Re: directory listing
    ... Dim strFile As String ... Dim strFolder As String ... Dim strPF As String 'Previous Folder ... Dim LineNum As Long ...
    (microsoft.public.excel.programming)