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

Sometimes you just miss the spot and while you want to have the same names on files for two different folders and you would like to do it the geek way

Photo by Drew Coffman on Unsplash
$path1="D:\Chiapas\timelapse2 02072020\Capture"
$path2="D:\Chiapas\timelapse2 02072020\Output"
$l1=gci -File -Path $path1 | select -ExpandProperty Basename
$l2=gci -File -Path $path2 | select -ExpandProperty baseName
Compare-Object -ReferenceObject $l1 -DifferenceObject $l2
Compare-Object -ReferenceObject $(gci "D:\Chiapas\timelapse2 02072020\Capture") -DifferenceObject $(gci "D:\Chiapas\timelapse2 02072020\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

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

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