|
-
Jul 24th, 2007, 02:44 PM
#1
Thread Starter
Fanatic Member
Compare folder contents
Guys,
I have 2 folders. How can I compare the contents, including sub-folders, and show the number of common files and total file count? I have a software build that should span 3 disks but I have a feeling that they have burnt disk 1 3 times and labelled incorrectly!!! Its hard to drill down as the folders get quite deep, everything looks the same so far.
Can anybody help me with a quick sub to loop thru and compare the folder structure and contents, please?
Thanks
Bob
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Jul 24th, 2007, 04:03 PM
#2
Re: Compare folder contents
The WinMerge utility in my signature supports that function, maybe that will save you some coding.
-
Jul 24th, 2007, 04:06 PM
#3
Re: Compare folder contents
vb Code:
Public Sub CompareFiles(ByVal directoryName As String)
'loop through files to see which are missing
For Each filename As String In IO.Directory.GetFiles(directoryName)
'replace current drive letter with one to compare to
Dim fileParts() As String = filename.Split(IO.Path.DirectorySeparatorChar)
'you could set require this as input to make it dynamic
fileParts(0) = "D:"
Dim compareDirectoryName As String = String.Join(IO.Path.DirectorySeparatorChar, fileParts)
If Not IO.File.Exists(compareDirectoryName) Then
'file missing
End If
Next
'loop through sub directories using recursion
For Each subDirectory As String In IO.Directory.GetDirectories(directoryName)
CompareFiles(subDirectory)
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|