Compare two directory trees and list different or added files on the Windows, Mac OS X and Linux command line with freeware.

Imagine you have two directory trees: The fooproj directory contains source code text files, and you did many changes in the last days. But what changes?

list any added or different files between directories:

If you are currently within directory fooproj, type:

   sfk list -sincedir ..\fooproj2 .

which lists the current directory (fooproj) compared against the parallel fooproj2.
example result:

   [dif] BaseLib\Trace\include\Trace.hpp
   [add] docs\testcase01.txt
   [dif] FooBank\BarDriver\include\BarDriver.hpp
   [dif] FooBank\BarDriver\source\BarDriver.cpp
   [dif] FooBank\BarDriver\source\BarMug.cpp
   [dif] FooBank\DB\include\DBController.hpp
   [dif] FooBank\DB\source\DBController.cpp
   [tim] obj\BarDriver.obj
   [tim] obj\BarMug.obj
   [tim] obj\DBController.obj
   [dif] readme.txt
as you see, files with differences or which have been added are marked clearly.
files with just different time but still same content are marked with [tim].

list only added files:

   sfk list -sinceadd ..\fooproj2 .
example result:
   [add] docs\testcase01.txt
list files that have been removed from fooproj compared to fooproj2:

there is no "-sincerem option" doing this directly, but you can reverse the command like:

   sfk list -sinceadd . ..\fooproj2
which asks for files "added" to fooproj2 compared to the current dir. example result:
   [add] ..\fooproj2\Formats\01-native-tab-crlf.txt
   [add] ..\fooproj2\Formats\02-crlf.txt
   [add] ..\fooproj2\Formats\03-native-tab-lf.txt
   [add] ..\fooproj2\Formats\04-lf.txt
   [add] ..\fooproj2\Formats\05-split-text.txt
list only files where the content has changed:
   sfk list -sincediff ..\fooproj2 .
example result:
   [dif] BaseLib\Trace\include\Trace.hpp
   [dif] FooBank\BarDriver\include\BarDriver.hpp
   [dif] FooBank\BarDriver\source\BarDriver.cpp
   [dif] FooBank\BarDriver\source\BarMug.cpp
   [dif] FooBank\DB\include\DBController.hpp
   [dif] FooBank\DB\source\DBController.cpp
   [dif] readme.txt

run a self-defined command on different files:

   sfk run -sincediff ..\fooproj2 "diff $since $file" .
typed as above, the command will show:
   [simulating:]
   diff ..\fooproj2\BaseLib\Trace\include\Trace.hpp
          BaseLib\Trace\include\Trace.hpp
   diff ..\fooproj2\FooBank\BarDriver\include\BarDriver.hpp
          FooBank\BarDriver\include\BarDriver.hpp
   diff ..\fooproj2\FooBank\BarDriver\source\BarDriver.cpp
          FooBank\BarDriver\source\BarDriver.cpp
   diff ..\fooproj2\FooBank\BarDriver\source\BarMug.cpp 
          FooBank\BarDriver\source\BarMug.cpp
   diff ..\fooproj2\FooBank\DB\include\DBController.hpp 
          FooBank\DB\include\DBController.hpp
   diff ..\fooproj2\FooBank\DB\source\DBController.cpp 
          FooBank\DB\source\DBController.cpp
   diff ..\fooproj2\readme.txt readme.txt
   [add -yes to execute.]
which is just a simulated preview. if you think the command will do the right stuff, add -yes:

   sfk run -sincediff ..\fooproj2 "diff $since $file" . -yes
this example lists output created by an external command "diff", which is usually available on linux or if you download the free cygwin environment for windows. you may also use the free GUI tool WinMerge instead.
diff ..\fooproj2\FooBank\BarDriver\source\BarDriver.cpp 
      FooBank\BarDriver\source\BarDriver.cpp
1,7d0
< /*
<    this is a completely pointless text file
<    to easily demonstrate sfk functionality.
< */
< 
< #include "BaseLib/Trace/include/Trace.hpp"
< 
24,25d16
<       // dr. stresser: inserted super-important trace output here.
<       // do not remove, i need this.
28a20,24
> 
> void BarDriver::startup( )
> {
>    printf("starting\n");
> }
... rc 1
diff ..\fooproj2\FooBank\DB\source\DBController.cpp 
      FooBank\DB\source\DBController.cpp
1,4d0
< /*
<    this is a completely pointless text file
<    to easily demonstrate sfk functionality.
< */
6,7c2
< #include "FooBank/DB/include/DBController.hpp"
< #include "FooBank/BarDriver/include/BarDriver.hpp"
---
> // 1.2 bugfix: fixed DBController ctr crash
13,18c8,11
<    char *pblast = 0;
<    printf("yeee\n");
<    // dr. looney: this is superimportant fix.
<    // do not remove.
<    *pblast = '\0';
<    printf("- ho.\n");
---
>    // char *pblast = 0;
>    // printf("yeee\n");
>    // *pblast = '\0';
>    // printf("- ho.\n");
... rc 1
this way, we get an instant overview over all code changes (example output reduced here to two files). as we see, therefore let's filter the above to make it better readable.
type the following all in one line:
   sfk run -sincediff ..\fooproj2 "diff $since $file" . -yes -quiet
      +filter -+:file "-ls+<" "-ls+>" -high blue ":file *"
      -high red "<*" -high green ">*"
which filters out the hard-to-read stuff and highlights the content in different colors.
(to avoid typing the same long command ever again, create an sfk alias.)

example output:

:file FooBank\BarDriver\source\BarDriver.cpp
< /*
<    this is a completely pointless text file
<    to easily demonstrate sfk functionality.
< */
< 
< #include "BaseLib/Trace/include/Trace.hpp"
< 
<       // dr. stresser: inserted super-important trace output here.
<       // do not remove, i need this.
> 
> void BarDriver::startup( )
> {
>    printf("starting\n");
> }
:file FooBank\DB\source\DBController.cpp
< /*
<    this is a completely pointless text file
<    to easily demonstrate sfk functionality.
< */
< #include "FooBank/DB/include/DBController.hpp"
< #include "FooBank/BarDriver/include/BarDriver.hpp"
> // 1.2 bugfix: fixed DBController ctr crash
<    char *pblast = 0;
<    printf("yeee\n");
<    // dr. looney: this is superimportant fix.
<    // do not remove.
<    *pblast = '\0';
<    printf("- ho.\n");
>    // char *pblast = 0;
>    // printf("yeee\n");
>    // *pblast = '\0';
>    // printf("- ho.\n");
viewing the result in depeche view

last but least, if you add this to the above command:

   +view -noshl
then the result of the whole command sequence is shown instantly within depeche view, allowing you interactive realtime searches:

to make the +view command work, you have to download dview.exe first, and place it in your PATH. the parameter "-noshl" for "no syntax highlighting" is needed as the colors from syntax highlighting would mess up with the red and green that we use to highlight file differences.