For example... I have txt file called New and txt file called Old... How can i create batch script to check both txt files and then create new text file with lines that aren't in both of them (New and Old txt files)? Thanks in advance...

  • 4
    If the lines aren't in either file how do you know what they are? – Daniel R Hicks Mar 16 '13 at 12:02
  • I just want to compare both txt files... I know what is in Old and i just want to know if there is something new in New txt file and then if there some new line that isnt in Old print that in new text file... – Noober Mar 16 '13 at 12:19
  • Why not open both up in notepad++ and set them to compare. It will also highlight where the differences are. That's if you are asking to compare code you made an error on and are looking for the differences to identify an area of possibility. – DᴀʀᴛʜVᴀᴅᴇʀ Mar 16 '13 at 18:38

I assume you meant to ask

How to check lines in two txt files and save lines that aren't in both of them in new text file?

A good command line tool is diff which you can get here for Windows. If that's what you are looking for then How can I get diff to show only added and deleted lines answers your question.

This question https://superuser.com/questions/56603/what-is-a-good-text-comparison-tool-for-windows lists comparison tools for Windows.

Wikipedia has a list of text comparison tools.

  • The classic answer would be to install a Linux partition or install Cygwin and use diff. – Daniel R Hicks Mar 16 '13 at 17:41
FC new.txt old.txt > diff.txt

You can also check the ERRORLEVEL of FC to have your script respond to the files being different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.