Figure out what files are missing from two paths in your Windows Machine using Powershell

In this article, I will comment step by step how to figure out what file is missing from one folder that another folder has it. Individually, I’ve been working processing files for hours, and now I got 599 records in one folder (all files with extension ARW). I got 598 files on another one (with extensions JPG), and I need to find out using PowerShell. What’s the file missing??

Photo by Drew Coffman on Unsplash

The Solution for the different extension is to compare the basename of the files attribute, which will be the same between them.

If all the files from path1 are in path2, you will get no output

If on the other hand there are more files on $path2 than in $path1 you’ll get something like this:

Path2 ($l2) has a file that ($l1) misses with name _7R36959

This indicates that the file _7R36959 is present on $l2 (that’s why the SideIndicator goes from ReferenceObject to DifferenceObject (=>). This says that there are more pictures revealed than the source, and it’s an impossible case.

To simulate this, I’ve moved the picture _7R36959.ARW to another folder.

The other case is more files on the source than the target (which is the expected result if you’re missing to post-process a picture).

Path1 ($l1) has a file that ($l2) misses with name _7R36959

This indicates that the file _7R36959 is present on $l1 (source), the side indicators go from referenceObject $l1 to differenceObject $l2 (<=)

Thank you very much for reading!

Follow me| Help me grow | MCP | MCSE| MS Technical Lead Exchange Online/Powershell | Experts-Exchange Awarded 2018 | TechNet 66k Downloads.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store