Are you trying to compare the contents of the folders by file name,
size and date or by performing a binary comparison of the contents
of the files?
I'm currently checking on size and created (by a lot of copy pasting) the
following:
Function CompareFolders (folder1, folder2, Lvl1, Lvl2, Lvl3) 'source folder,
destination folder
Dim fso, fo1, fo2, fi1, fi2, f
Set fso = CreateObject("scripting.filesystemobject")
Set fo1 = fso.getfolder(folder1)
If fso.FolderExists(folder2) Then
Set fo2 = fso.getfolder(folder2)
Set fi1 = fo1.Files
For Each f In fi1
If fso.fileexists(fo2.Path & "\" & f.Name) Then
Set fi2 = fso.getfile(fo2.Path & "\" & f.Name)
If fi2.Size <> f.Size Then
logtxt = f.path & " not copied correctly"
Loglvl Lvl1, logtxt
wscript.echo f.path & " not copied correctly"
End If
Else
logtxt = "Missing file: " & f.path
Loglvl Lvl2, logtxt
Wscript.echo "Missing file: " & f.path
End If
Next
dim s
for each s in fo1.subfolders
Aspad = split(s.path, folder1, -1, 1)
Sspad = Aspad(1)
sfolder2 = folder2 & Sspad
If fso.FolderExists(sfolder2) Then
CompareFolders s.path, sfolder2, Lvl1, Lvl2, Lvl3
Else
logtxt = sfolder2 & " doesn't exist"
Loglvl Lvl3, logtxt
wscript.echo sfolder2 & " doesn't exist"
End If
next
Else
logtxt = folder2 & " doesn't exist"
Loglvl Lvl3, logtxt
wscript.echo folder2 & " doesn't exist"
End If
End Function
The Loglvl part is used to write to a html log.
any tips or tricks?
regards,
jeroen
dir d:\temp\*.txt /s /b
will generate an output of the form
D:\temp\Temp\xxcopy.txt
D:\temp\Netgear\NetGear\HELP\DIAG.TXT
D:\temp\Netgear\NetGear\HELP\INST_DOS.TXT
D:\temp\Netgear\NetGear\HELP\README.TXT
which seems perfectly suited for my purposes. All I need to
do is this:
1. Pick up one line at the time.
2. Replace D:\Temp with \\server\share\folder (for example).
3. See if the target file exists.
4. See if the file sizes are the same.
This is exactly what the following function does. As I said,
it's an application of the KISS principle.
F1 = UCase("d:\Temp")
F2 = UCase("d:\Thu")
Compare F1, F2
Sub Compare (Folder1, Folder2)
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set ObjWshShell = WScript.CreateObject("WScript.Shell")
Set StdOut = WScript.StdOut
Set ObjExec = ObjWshShell.Exec("%ComSpec% /c dir /s /b " _
& """" & Folder1 & "*.txt""")
Do While Not ObjExec.StdOut.AtEndOfStream
File1 = UCase(ObjExec.StdOut.ReadLine)
File2 = Replace(File1, F1, F2, 1, 1)
If ObjFSO.FileExists(File2) Then
Set F1 = ObjFSO.GetFile(File1)
Set F2 = ObjFSO.GetFile(File2)
If Not F1.Size = F2.Size Then
'Sizes are different - put your own code here
End If
Else
'File does not exist - put your own code here
End If
Loop
End Sub
"Jeroen" <Jer...@discussions.microsoft.com> wrote in message
news:0CA02B52-0B5C-4A6C...@microsoft.com...
To do this there is one Utility available from Microsoft,
search for windiff
i think its available in XP SP2 Supprt tools
--
Regards,
Chaitanya Shah