Dec 112017
 
Compare DIR's for common/different files. Includes C source code.
File DIRCMP2.ZIP from The Programmer’s Corner in
Category File Managers
Compare DIR’s for common/different files. Includes C source code.
File Name File Size Zip Size Zip Type
DIRCMP.C 13842 4828 deflated
DIRCMP.DOC 4093 1674 deflated
DIRCMP.EXE 11776 6138 deflated

Download File DIRCMP2.ZIP Here

Contents of the DIRCMP.DOC file


dircmp compares two directories. Execute by
dircmp [flags] path_a path_b

Flags are single characters preceeded by '-':
-a Print filenames of files in path_a and not in path_b
-b Print filenames of files in path_b and not in path_a
-m Print filenames of files in both path_a and path_b
(path_a is output. See -p flag below)
-p Prefix file name with its entire path
-f Prefix a %1 and suffix a %2 to each line
-e Extended compare includes date/time in comparison

The path_a and path_b are similar to the parameters to DOS COPY command).

The output is sent to STDOUT and, therefore, may be redirected.

=======================================================================

Basically, dircmp compares the directories at the end of two paths and
displays selected comparisons on STDOUT. Selections can include "files
which are in the directory at the end of the first path (path_a) but not
in the directory at the end of the second path (path_b)", "files which
are in ... of the second path but not in ... of the first path", and
"files which are found in both directories".

The comparison is normally by file name and extension only, but the -e
option may be used to extend the comparison to include the file date and
time stamps. The "path_a but not path_b" type comparison is converted
to "the file is present in path_a but not in path_b OR the file exists
in both directories but the date/time stamp of the file in path_a is
greater than the file in path_b".

The -p option causes the selected path (path_a for the -a and -m options
and path_b for the -b option) to be prefixed to the filename. Thus a
unique name is generated. The -f option adds .BAT file positional
parameters to the beginning and end of the file name. Coupled with
redirection of the output to a .BAT file, this will create the commands
necessary to update directories or clean them up.

Example:

dircmp -aefp a: c:\util >doit.bat

will create a file named doit.bat with a list of all files on the a:
drive root directory which are "newer" than the files on the c:
drive in the util directory. To update the c:\util directory, you
would enter:

doit copy c:\util

The doit.bat file contains:

%1 a:\dircmp.exe %2
%1 a:\dxyz.doc %2
....
%1 a:\zzz.com %2

and will generate:

copy a:\dircmp.exe c:\util
copy a:\dxyz.doc c:\util
....
copy a:\zzz.com c:\util

Notice that the output of dircmp is sorted by file name. I have issued
the following commands to create a sorted diskette.

dircmp -afp c:\util NUL: >doit.bat
doit copy a:

All the files in the c:\util directory are output to doit.bat in
sort order by file name and extension. The execution of doit then
copies these files (in order) to the a: drive.

When I carry work from office to home on a diskette, I can easily tell
what I have changed since the last time. When coupled with a program
like "Beyond Compare" from General Transformations, I can easily find
the exact differences between two sets of files. Dircmp tells me which
files have changed and BC tells me where these have changed.

Note: dircmp ? will list the basic documentation, if you forget.


I release this program to the public domain with all the usual caveats.
I do not warranty it and am not responsible for the consequences of it's
use. It may be freely copied and distributed provided no charge is made
in any form for the program. You may extract from it and use it in your
code provided that the resultant program is not sold for profit. If you
wish to use it commercially or extract from it for a commercial program,
please call me, I'm reasonable. I have modified a routine published
first in Dr. Dobbs magazine to work with DeSmet C. It's credits are
retained in the source.

Have fun.


Richard Threlkeld, CPA
2101 Stonehill Ct
Arlington, Tx 76012
(817) 265-6943 (office)
(817) 261-3527 (home)



 December 11, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)