How can I compare two folders to find missing files?

July 9, 2025 4 answers
Asked by ticket.stub.
Hey everyone! I'm trying to compare two folders that contain a lot of subfolders to identify any missing files. I recently converted around 25,000 audio files, but some of them didn't transfer over to the output folder. The original files had various formats (like FLAC, MP3, M4A, WAV, OGG), but the converted ones are all in OGG format. Even though the file names and their locations within the folders should match, I'm having trouble figuring out which ones are missing. Any advice on how to tackle this? Thanks! :)

Answers

3.parts.water
Hereโ€™s a neat little script that might work for you: ```powershell $folderA = "C:filesFolderA" $folderB = "C:filesFolderB" function Get-RelativePathNoExt { param ([string]$basePath, [string]$fullPath) $relativePath = $fullPath.Substring($basePath.Length).TrimStart('') [System.IO.Path]::ChangeExtension($relativePath, $null) } $filesA = Get-ChildItem -Path $folderA -Recurse -File $filesB = Get-ChildItem -Path $folderB -Recurse -File $setA = $filesA | ForEach-Object { Get-RelativePathNoExt -basePath $folderA -fullPath $_.FullName } $setB = $filesB | ForEach-Object { Get-RelativePathNoExt -basePath $folderB -fullPath $_.FullName } diff = $setB | Where-Object { $_ -notin $setA } Write-Host "Files in $folderA but not in $folderB :" $diff | ForEach-Object { Write-Host $_ } ``` This should give you a list of files that are missing in your output folder.
Reply to this answer
mushroom identification
You can use PowerShell to compare the two folders easily. Just use these commands: ```powershell $SourceFiles = Get-ChildItem -path $SourcePath -Recurse $TargetFiles = Get-ChildItem -path $TargetPath -Recurse $Missing = Compare-Object -ReferenceObject $SourceFiles -DifferenceObject $TargetFiles -Property BaseName ``` This will help you identify which files from your source are missing in the target.
Reply to this answer
dill fronds
Have you tried running any code yet? It might help if you share what you've implemented so far so others can give targeted help.
Reply to this answer
3am ferry delay
If you want something more visual than command line, check out Beyond Compare from Scooter Software. Itโ€™s not PowerShell, but it can be scripted and is by far the best comparison tool Iโ€™ve used!
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions