We help IT Professionals succeed at work.

compare two directories, echo out which files are not the same

246 Views
Last Modified: 2018-02-22
Hey Experts.  I have two directories (A and B).  Almost all of the 200 files that are in A and B are the same except for maybe 10 or 20.  The 10 or 20 files have a different size and modified date.  I just want to run a script that compares the two directories and if file a in dir A and B differ, it's logged.  This is unfortunately outside my feeble abilities but I'm sure there is a scripting master that can do it (in batch, preferred).

Thank you in advance!
Comment
Watch Question

Team Lead RRS Desk
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
aravind ancheWindows/Vmware
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
aravind ancheWindows/Vmware
CERTIFIED EXPERT

Commented:
Also please check   the below link, It has the script to compare folders

https://gallery.technet.microsoft.com/scriptcenter/PowerShell-Compare-Folders-2c0b61e6
aravind ancheWindows/Vmware
CERTIFIED EXPERT

Commented:
if you are doing c drive and D drive

compare (ls $C -Recurse) (ls $D -Recurse)

if you are comparing folders named test1 and test 2 in c drive

compare (ls c:\test1 -Recurse) (ls c:\test02 -Recurse)

Author

Commented:
Thank you for the quick reply!  I really like this script!  How do I output it to a log file though?

@echo off
if "%2" == "" GOTO Usage

cd /D %1
if errorlevel 1 goto usage

for %%x in (*.*) do if NOT exist %2\%%x echo missing %2\%%x
cd /D %2
for %%x in (*.*) do if NOT exist %1\%%x echo missing %1\%%x

goto end

:usage
echo Usage %0 dir1 dir2
echo where dir1 and dir2 are full paths
:end

Open in new window

Author

Commented:
Thanks DJ!  Going to check into your suggestions next.
Edward PamiasTeam Lead RRS Desk
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Joe WinogradDeveloper
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2018
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Edward PamiasTeam Lead RRS Desk
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Haven't forgotten this, just trying to close out the office 2016 migration and deal with a couple of fires.  I will be back for you!
Edward PamiasTeam Lead RRS Desk
Top Expert 2016

Commented:
We are not going anywhere.

Author

Commented:
Thanks everyone for your help and time.  Due to time constraints, I didn't get into all of the options like I wanted to but I awarded the options as best as I could.  I appreciate your understanding.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.