CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2010

    [RESOLVED] Anyone know of a script (perhaps Perl or some other scripter) that can

    take the output of the command dir /S > file1.out and dir /S > file2.out (ie. those two files) and make a 3rd file or at least print to the screen so I can redirect it that shows only the differences in those two files.

    This would be easy in C++ - just read in each line, compare the strings, and only print out if they are not the same. Easy.

    But I want this done with a script if possible. And it has to be on Windows 10 because the files are too big to email. They are about 100 MB+.

    This way I can tell exactly what files have changed after installing a piece of software.

    If I don't here back, I'll probably just write something. But I'm not sure I have Perl on my Windows machine. Or much from the Linux utilities.

    Just curious if this kind of tool has been gifted over to the user world or do I have to roll my own.

  2. #2
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: Anyone know of a script (perhaps Perl or some other scripter) that can

    From the command prompt you could use fc to compare the 2 files.

    c:\MyProgs>fc /?
    Compares two files or sets of files and displays the differences between
    FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn]
       [drive1:][path1]filename1 [drive2:][path2]filename2
    FC /B [drive1:][path1]filename1 [drive2:][path2]filename2
      /A         Displays only first and last lines for each set of differences.
      /B         Performs a binary comparison.
      /C         Disregards the case of letters.
      /L         Compares files as ASCII text.
      /LBn       Sets the maximum consecutive mismatches to the specified
                 number of lines.
      /N         Displays the line numbers on an ASCII comparison.
      /OFF[LINE] Do not skip files with offline attribute set.
      /T         Does not expand tabs to spaces.
      /U         Compare files as UNICODE text files.
      /W         Compresses white space (tabs and spaces) for comparison.
      /nnnn      Specifies the number of consecutive lines that must match
                 after a mismatch.
                 Specifies the first file or set of files to compare.
                 Specifies the second file or set of files to compare.
    or use comp

    c:\MyProgs>comp /?
    Compares the contents of two files or sets of files.
    COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]
      data1      Specifies location and name(s) of first file(s) to compare.
      data2      Specifies location and name(s) of second files to compare.
      /D         Displays differences in decimal format.
      /A         Displays differences in ASCII characters.
      /L         Displays line numbers for differences.
      /N=number  Compares only the first specified number of lines in each file.
      /C         Disregards case of ASCII letters when comparing files.
      /OFF[LINE] Do not skip files with offline attribute set.
    To compare sets of files, use wildcards in data1 and data2 parameters.
    Last edited by 2kaud; August 25th, 2017 at 02:05 PM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.7.4)

  3. #3
    Join Date
    Nov 2010

    Re: Anyone know of a script (perhaps Perl or some other scripter) that can

    Thanks, I ran fc on the files - it seems to have showed some proper differences. I just need to examine the files now and see if it ran correctly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.