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

Sometimes you 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

☝ THE REQUIREMENT ☝

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

🙋Why❓ Because democratizing my thoughts and solutions it’s a good pill for myself.

🔨 Who AM I? 🔨

My name is Jose Ortega, and I’m a Microsoft Certified Professional🎆 on Office 365, Powershell, Messaging (Exchange Online/Exchange On-premises), and Windows Server. I’ve been working with Microsoft Technologies for 12+ years and independently since 2015 using Upwork and reaching the distinction of Top-Rated Plus Freelancer. I used to write scripts for TechNet in my free time, but now I’ve moved to Medium; my goal is to help you solve complicated and straightforward problems with my experience. You can expect an article from one to three weeks. Right now, I’m working and assisting on a Microsoft GIG as a freelancer for Office365 tickets and customers worldwide. Thank you in advance for all the support, follow, clap, comment, and donation. If you would like to ask something or discuss it further, please reach me on social networks (Twitter, Instagram, Facebook, or GitHub as j0rt3g4).

Support my content by subscribing to Medium using: https://j0rt3g4.medium.com/membership (using this link to subscribe to Medium will give a tiny commission to me from your monthly fee)

Would you like to have my stories in your mailbox: https://j0rt3g4.medium.com/subscribe

🙌THE SOLUTION 🙌

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

$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

Because I know you love oneliner, what about one for this?

Compare-Object -ReferenceObject $(gci "D:\Chiapas\timelapse2 02072020\Capture") -DifferenceObject $(gci "D:\Chiapas\timelapse2 02072020\Output")

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 arrow says that more pictures are 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 (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 (<=)

Medium 👏 NETWORKING 🔗 SECTION 🏰

Photo by Duy Pham on Unsplash

If you liked this article or require help to reach 100 subscriptions, drop a note in my previous article; if you don’t get an answer or Follow back, write me; my contacts are below.

Let’s quick thinking that I’m not doing Following you thinking, and I will follow you and read you when I have a Lil time this weekend let’s not feed the anger or hate , let’s think that the people are trying to live their lives the best they can with the knowledge they have at the moment.

Leave a comment/Follow me here (✅ to be — Added✅):

Or follow :) I’d add you if I see that your follower’s number is less than 100 and if you already have started writing at least one history!

Also, on this networking topic, I’ve created a challenge on my page:

The things are simple, go to the page and add yourself, then move to the “Randomize Page” and get a list of 3 to 6 people to follow that were already registered, this was an effort to help people to get more than 100 viewers fast, but sadly nobody has even written there, which is a little sad! At least it is there at disposition.

Photography 📷 and Video 📹 section

In case you’re interested my photography, please visit any of these: jgocfoto, on socials: Instagram, Facebook, Instagram, Youtube, 500px, 100asa, youpic, pexels, unsplash, adobe stock.

Thank you very much for reading. Any comments you can contact me over social networks (Twitter, Instagram, Facebook, or GitHub as j0rt3g4), or over teams/email if you prefer jortega@faboit.com. I want to know from you, leave your comments or doubts and share this information if you think it was helpful in any way for you.

Thank you very much for reading. Any comments you can contact me over social networks (Twitter, Instagram, Facebook, or GitHub as j0rt3g4), or over teams/email if you prefer jortega@faboit.com. I want to know from you, leave your comments or doubts and share this information if you think it was helpful in any way for you.

--

--

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
Jose Gabriel Ortega C

Jose Gabriel Ortega C

Powershell Expert | Office365 Ambassador | MS Certified Pro | Awarded in Experts-Exchange | Twitter: j0rt3g4 YT: j0rtIT