1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    Dismiss Notice
  4. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Batch] Comparing Text Files

Discussion in 'Computer Tech' started by Ironside, Apr 29, 2010.

  1. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    Is it possible in batch, that it would compare 2 text files, and write everything that the 1st file hasn't that the 2nd one has into a 3rd text file?

    I need it so I can finish my batch file, but I can't talk about it here, as it is against the rules...
     
  2. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    Comparing files in batch is possible I think, but writing everything one has which the other doesn't have is harder and I doubt it's possible. Just use C++ or Java or something similar.
    You can easily run other batch files from a C++/Java program and vice versa.
     
  3. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    I know it's easier in other languages, but I'm a complete amatur in c++ and I don't know anything about Java at all....

    I tried it with VB, but it was too advanced for my level...

    So I'm kinda asking if someone is willing to do it for me in any language at all.
     
  4. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    I could probably make something like that in Java.

    Edit: Do you want to check for certain words or do you want to check each file as a string and then compare the characters in that string?

    F.ex.
    File 1:
    "asdasd"

    File 2:
    "esdasf"

    File 3:
    "ef"


    Edit: Here it is, I did it like in that example I added, but it checks for things File 1 has which File 2 doesn't have (not what File 2 has which File 1 doesn't have) and it's easy to use. Just make a batch file and put it in the same folder as the .jar file below and do
    "File Comparer.jar" <File 1> <File 2> <Result file>

    Example:
    "File Comparer.jar" Rofl.txt Omg.txt MUahahahahah.txt


    If you get any errors or if it's not working correctly please notify me.
     

    Attached Files:

    Last edited: May 1, 2010
  5. swipe5weep

    swipe5weep

    Joined:
    Mar 22, 2009
    Messages:
    273
    Resources:
    0
    Resources:
    0
    It is possible to write the content of a text file into another text file but i don't think it can compare the contents it has. It maybe possible with some programming languages.
     
  6. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    The thing is, the 2nd file will always have a few lines more than the 1st text file.
    And all lines that the 1st doesn't have and the 2nd has should be writen in the 3rd file

    Also 1st file can never have something the 2nd hasn't got
     
  7. swipe5weep

    swipe5weep

    Joined:
    Mar 22, 2009
    Messages:
    273
    Resources:
    0
    Resources:
    0
    I am not sure if string subtraction is possible in batch.
    Like:
    A = Contents of a.txt
    B = Contents of b.txt
    C = B - A

    We may be able to do that but my mind can't think today. lol
     
  8. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    I know it can be done, just not in batch... I heard that for one among the others VB could do it.
     
  9. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    The java file I came with supports different file sizes and it doesn't care if the first (or second in the Java app) file got stuff the other file doesn't have.
     
  10. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    It doesn't matter if it checks if the 1st is bigger than the 2nd aslong as it checks that the 2nd is bigger than the 1st aswell.
     
  11. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    It checks both files. I added it to ensure it wouldn't fuck up trying to compare data which doesn't exist and stuff.
     
    Last edited: May 2, 2010
  12. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    It's no problem if it checks both files.
     
  13. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    Good ^^

    I failed in the post above :D
    I said "I added it to ensure it would fuck up" when it should be "I added it to ensure it wouldn't fuck up" xD
     
  14. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    Yeah I noticed :p