1

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...

3
  • 4
    If the lines aren't in either file how do you know what they are? Mar 16, 2013 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, 2013 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. Mar 16, 2013 at 18:38

3 Answers 3

1

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.

1
  • The classic answer would be to install a Linux partition or install Cygwin and use diff. Mar 16, 2013 at 17:41
0
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.

0

To perform a test on two txt files and save the differences in a new text file in Windows, you can use the "fc" command in the Command Prompt. Here are the steps to follow:

Open the Command Prompt by searching for "cmd" in the Start menu or pressing the Windows key + R and typing "cmd" in the Run dialog box.

Navigate to the directory where the two txt files are located by using the "cd" command followed by the directory path. For example, if the files are located in the Documents folder, type "cd C:\Users\YourUsername\Documents" and press Enter.

Type the following command to compare the two txt files: fc file1.txt file2.txt > differences.txt

Replace "file1.txt" and "file2.txt" with the names of the two txt files you want to compare. Replace "differences.txt" with the name you want to give to the new text file that will contain the differences between the two files.

Press Enter to execute the command. The Command Prompt will compare the two txt files and write the differences to the new text file.

Navigate to the directory where the new text file was created to view its contents. For example, if you named the file "differences.txt" and saved it in the Documents folder, type "cd C:\Users\YourUsername\Documents" and press Enter, then type "notepad differences.txt" and press Enter to open the file in Notepad.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .