2

I have a larger folder containing all my SVN files. I got attacked my a virus destroying some files but also corrupting SVN config files, so now TortoiseSVN cannot recognize it as a SVN folder.

I can redownload the repository to other location but there are some files I didn't commit to it.

Is there some software that can tell me difference in contents between folders or should I write a batch script that can tell me which files were not commited?

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400
Vlad
  • 137

4 Answers4

2

One of the ways to compare 2 directories is using the TREE command.

TREE  D:\SOURCE /A /F >D:\SOURCE.TXT

TREE  D:\DEST /A /F >D:\DEST.TXT

Then use WinDiff or DiffChecker to compare the two text files.

How to Compare Two Directories And Find Out the Differences?

w32sh
  • 12,379
1

Another alternative is WinMerge:

WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400
codaamok
  • 1,393
0

The Oxygen XML editor package (or Author or Developer packages) offers a GUI directory diff tool that also allows you to easily copy changes from one file tree to another.
A 30-day trial license is free, main site here. There's also a GUI file diff tool.

WBT
  • 1,922
0

This PowerShell script will compare 2 folders, recursively. It'll output the list of:

  • Files that are missing in Folder1 (but present in Folder2).
  • Files that are missing in Folder2 (but present in Folder1).
  • Files that exist in both but are different.
  • Files that are identical in both folders.
param(  
    [Parameter(Mandatory=$true)]  
    [string]$FolderPath1,
[Parameter(Mandatory=$true)]  
[string]$FolderPath2  

)

Ensure paths end with backslash for consistent path handling

if (-not $FolderPath1.EndsWith('')) {
$FolderPath1 += ''
}

if (-not $FolderPath2.EndsWith('')) {
$FolderPath2 += ''
}

Get all files recursively from both directories

$files1 = Get-ChildItem -Path $FolderPath1 -Recurse -File
$files2 = Get-ChildItem -Path $FolderPath2 -Recurse -File

Create hashtables mapping relative file paths to full paths

$files1Rel = @{}
foreach ($file in $files1) {
$relativePath = $file.FullName.Substring($FolderPath1.Length)
$relativePath = $relativePath.TrimStart('')
$files1Rel[$relativePath] = $file.FullName
}

$files2Rel = @{}
foreach ($file in $files2) {
$relativePath = $file.FullName.Substring($FolderPath2.Length)
$relativePath = $relativePath.TrimStart('')
$files2Rel[$relativePath] = $file.FullName
}

Get all unique relative paths from both folders

$allRelativePaths = $files1Rel.Keys + $files2Rel.Keys | Sort-Object -Unique

Initialize arrays to hold comparison results

$missingInFolder1 = @()
$missingInFolder2 = @()
$filesDifferent = @()
$filesIdentical = @()

Compare files based on relative paths

Write-Host "Comparing files:" foreach ($relativePath in $allRelativePaths) { $file1Exists = $files1Rel.ContainsKey($relativePath) $file2Exists = $files2Rel.ContainsKey($relativePath) Write-Host "Comparing file: $relativePath"

if ($file1Exists -and $file2Exists) {  
    # Files exist in both folders, compare content  
    $file1Path = $files1Rel[$relativePath]  
    $file2Path = $files2Rel[$relativePath]  

    # Compare file sizes first for quick difference detection  
    $file1Info = Get-Item -Path $file1Path  
    $file2Info = Get-Item -Path $file2Path  

    if ($file1Info.Length -ne $file2Info.Length) {  
        $filesDifferent += $relativePath  
    } else {  
        # Compute file hashes to compare content  
        $hash1 = Get-FileHash -Path $file1Path -Algorithm MD5  
        $hash2 = Get-FileHash -Path $file2Path -Algorithm MD5  

        if ($hash1.Hash -eq $hash2.Hash) {  
            $filesIdentical += $relativePath  
        } else {  
            $filesDifferent += $relativePath  
        }  
    }  
} elseif ($file1Exists -and -not $file2Exists) {  
    # File is missing in FolderPath2  
    $missingInFolder2 += $relativePath  
} elseif ($file2Exists -and -not $file1Exists) {  
    # File is missing in FolderPath1  
    $missingInFolder1 += $relativePath  
}  

}

Output the comparison results

Write-Host "Files missing in $FolderPath1 (present in $FolderPath2):"
if ($missingInFolder1.Count -gt 0) {
$missingInFolder1 | ForEach-Object { Write-Host $_ }
} else {
Write-Host "None"
}

Write-Host "`nFiles missing in $FolderPath2 (present in $FolderPath1):"
if ($missingInFolder2.Count -gt 0) {
$missingInFolder2 | ForEach-Object { Write-Host $_ }
} else {
Write-Host "None"
}

Write-Host "`nFiles that are different:"
if ($filesDifferent.Count -gt 0) {
$filesDifferent | ForEach-Object { Write-Host $_ }
} else {
Write-Host "None"
}

Write-Host "`nFiles that are identical:"
if ($filesIdentical.Count -gt 0) {
$filesIdentical | ForEach-Object { Write-Host $_ }
} else {
Write-Host "None"
}

Usage:

.\Compare-Folders.ps1 -FolderPath1 "C:\Path\To\Folder1" -FolderPath2 "C:\Path\To\Folder2"  

Example of output:

Files missing in M:\robocopy-boloss\move\CrystalDiskInfo8_17_2\ (present in N:\robocopy-boloss\move\CrystalDiskInfo8_17_2\):
None

Files missing in N:\robocopy-boloss\move\CrystalDiskInfo8_17_2\ (present in M:\robocopy-boloss\move\CrystalDiskInfo8_17_2): None

Files that are different: ReadMe.txt

Files that are identical: CdiResource\AlertMail.exe CdiResource\AlertMail4.exe CdiResource\AlertMail48.exe CdiResource\dialog\flot\excanvas.min.js CdiResource\dialog\flot\jquery.flot.min.js CdiResource\dialog\flot\jquery.min.js CdiResource\dialog\Graph.css CdiResource\dialog\Graph.html

Notes:

  • Before computing file hashes (which can be time-consuming for large files), the script first compares file sizes for a quick check.
  • The script uses the MD5 algorithm for hashing; you can change it to SHA256 or another algorithm supported by Get-FileHash if needed.
Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400