home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / diffx.zip / DIFF.ZIP / DIFF.TXT < prev    next >
Text File  |  1990-07-03  |  18KB  |  479 lines

  1. DIFF
  2.  
  3. version 1.2
  4. 7-2-90
  5.  
  6.  
  7.  
  8. What it is . . .
  9.       DIFF is a program that will check to see if any files in a specified
  10. directory tree have changed since the last time the utility was run.
  11.  
  12.  
  13. Why use it . . .
  14.       If you want to find out what files have changed recently in a certain
  15. directory (or directory tree), DIFF will come in handy.  It is especially
  16. helpful on a network where many people may have access to certain files that
  17. you need to keep track of.  There are some useful examples of DIFF toward the
  18. end of this document.
  19.  
  20.  
  21. How it does it . . .
  22.       DIFF creates either one or two files for its own use depending upon how
  23. you wish to use it.
  24.  
  25.       The first is a Benchmark file containing the date and time of the last
  26. time the utility was run.  It also contains a list of all of the files in the
  27. directory along with their dates, times, and sizes as they were at the time
  28. the Benchmark file was created.
  29.  
  30.       Here is a portion of a Benchmark file:
  31.  
  32.       ;DIFF Benchmark created   7-2-1990 at 15:10
  33.       ;File sizes, dates, and times in directory:
  34.       ;
  35.       >C:\*.*
  36.       IO      .SYS      33337  12-19-1988   0:00:02
  37.       MSDOS   .SYS      37376  04-19-1989   8:38:32
  38.       DOUG'S                0  04-25-1990  14:33:30
  39.       BIZLINK          <DIR>   06-06-1990   9:22:18
  40.       DOS              <DIR>   04-25-1990  14:02:46
  41.       WP51             <DIR>   04-25-1990  14:25:52
  42.       AUTOEXEC.BAT       1668  07-02-1990  11:10:36
  43.       COMMAND .COM      37557  12-19-1988   0:00:02
  44.       CONFIG  .SYS        370  07-02-1990  13:58:12
  45.       ;
  46.       >C:\BIZLINK\*.*
  47.       DOUG             <DIR>   06-06-1990   9:24:34
  48.       ATTACH  .WPM       3739  05-24-1990   0:00:00
  49.       ATTCHCTL.CMD      18258  06-18-1990   0:00:00
  50.       BIZLINK .CMD      43434  06-18-1990   0:00:00
  51.       BIZLINK .EXE      48556  06-06-1990   0:00:00
  52.       ;
  53.  
  54.       Notice that DIFF picks up Hidden, System, and Read Only files (IO.SYS
  55. and MSDOS.SYS).  The file 'DOUGS' is acutally not a file, but the Volumne
  56. label on drive C:.  You'll also notice that DIFF considers seconds on a file's
  57. time stamp to be significant (DOS doesn't display them, but they are there). 
  58. Even if someone resets the clock to the date and time that DOS display for a
  59. particular file and then modifies that file, DIFF will likely report a
  60. difference due to the seconds.
  61.  
  62.       The second file (if you tell DIFF to create it) is a Difference file
  63. containing a list of all of the files that have been changed (according to
  64. date, time, and filesize) since the Benchmark file was created.
  65.  
  66.       Here is a portion of a Difference File:
  67.  
  68.       ;
  69.       ;DIFF Difference file created  7-2-1990 at 15:19
  70.       ;Benchmark file used: 'DIFF.LOG'.
  71.       ;
  72.       >C:\LIBRARY\*.*
  73.       DM_}ED  .SET        332  07-02-1990  15:12:22  Time
  74.       ;    1 - Difference(s)
  75.       ;
  76.       >C:\TC\WORK\DIFF\*.*
  77.       DIFF    .EXE     154363  07-02-1990  15:19:06 Size Time
  78.       DIFF    .LOG     155746  07-02-1990  15:10:52 Size Date Time
  79.       DIFF    .OBJ      19380  07-02-1990  15:19:02 Size Time
  80.       DIFF    .DIF        766  07-02-1990  15:15:36 Added
  81.       DIFF    .PRJ      32643  07-02-1990  15:19:06 Size Time
  82.       DIFF    .CPP      26598  07-02-1990  15:18:46 Size Time
  83.       DIFF    .BAK      26615  07-02-1990  15:14:38 Deleted
  84.       ;    7 - Difference(s)
  85.       ;
  86.       ;  113 - total Directories processed
  87.       ; 3255 - total Items processed
  88.       ;    8 - total Difference(s)
  89.  
  90.       Note that DIFF will find HIDDEN directories that are newly added or
  91. deleted but will not check any files inside hidden directories for differenc-
  92. es.  See the note about 'A Little Trick' below.
  93.  
  94.       When DIFF checks your files, it reads the Benchmark file and compares it
  95. against the current contents of the directories that you told it to check.  If
  96. it finds files that have been changed, it writes a list of them to a Differ-
  97. ence file (and/or optionally, to the screen).
  98.  
  99.  
  100. Running it . . .
  101.       DIFF has many options that tell it exactly what you want it to do.  Each
  102. time you run it, DIFF will essentially do one of two things, create a
  103. Benchmark file, or check a directory against an existing Benchmark file.
  104.  
  105. Usage:  DIFF option [option...] [path\filespec]
  106.  
  107.      ■      When running DIFF, you can have DIFF.EXE anywhere that DOS can
  108.             find it (in the current directory or in your path).
  109.      ■      You may specify any of DIFF's options in any order whatsoever.
  110.      ■      If you specify two conflicting options (like /D and /N) the last
  111.             one encountered will take precedence over the prior one.
  112.      ■      You must separate each option with a space.  If you do not, DIFF
  113.             will not be able to distinguish between them.  For example, DIFF
  114.             will interpret 'DIFF /M/O' incorrectly (DIFF will think you meant
  115.             'DIFF /M-O'.
  116.      ■      The dash '-' characters in certain parameters are necessary,
  117.             without them, DIFF will get confused about what you intended it to
  118.             do.  Actually, the dash could be any character (as long as there
  119.             is something there DIFF doesn't care what is used).  You could say
  120.             'DIFF /M/O' and DIFF would think you meant 'DIFF /M-O' and would
  121.             create a Benchmark file named 'O' in the current directory.
  122.      ■      If you do not specify any options, DIFF displays its help screen.
  123.  
  124.       Since there are so many different command line options, the following
  125. section will explain each one in further detail.
  126.  
  127.  
  128. The Finer Points
  129.       This is part of DIFF's help screen.  It displays a quick summary of each
  130. option.
  131.  
  132. Options
  133.   /M-filename Make Benchmark file using 'filename'
  134.   /C-filename Check directory using 'filename' as a Benchmark.
  135.   /D-filename Write Difference file to 'filename.'
  136.   /R-levels   Recursive operation.  Levels = the number of dir levels to scan.
  137.   /S          Screen display on.  Echos Difference file to screen.
  138.   /N          No Difference file.  (Implies /S)
  139.   /U          Unchanged files displayed and/or written in Difference file.
  140.   /O          Overwrite old Benchmark file with the newly created one.
  141.   /A          Append to Benchmark or Difference file (depends on /M or /C).
  142.   /H          Display this help screen.
  143.   path        The 'path' to begin working in (MUST END WITH A BACKSLASH)!
  144.   filespec    The filename mask (e.g. '*.*') to use in 'path.'
  145.  
  146. Examples
  147.   DIFF /M /O  Make a Benchmark file of the current dir named DIFF.LOG
  148.   DIFF /C     Check Benchmark DIFF.LOG against current directory
  149.               and write differences to DIFF.DIF
  150.  
  151.  
  152.  
  153. /M-filename
  154.  
  155.       Make a Benchmark file using 'filename'.  If 'filename' is not specified,
  156. the name DIFF.LOG is used.  This tells DIFF to create a Benchmark file named
  157. DIFF.LOG in the current directory.  Optionally you can specify a full path and
  158. filename to tell DIFF to create the Benchmark somewhere else.
  159.  
  160.  
  161.  
  162. /C-filename
  163.  
  164.       Check a directory (or directory tree) against 'filename.'  If 'filename'
  165. is not specified, the name DIFF.LOG is used.  This tells DIFF to compare a
  166. directory (or directory tree) against the files and directories listed in the
  167. Benchmark file.  DIFF compares each file that it finds against the information
  168. included in the Benchmark file, and if anything is different (size, date, or
  169. time), it reports what has changed by writing it to a file or to the screen
  170. (depending upon the /S and /N options).
  171.  
  172.  
  173.  
  174. /D-filename
  175.  
  176.       Create a Difference file named 'filename.'  If 'filename' is not
  177. specified, the name DIFF.DIF is used.  This option is only needed if you wish
  178. to use a different Difference file name.
  179.  
  180.       This option is only valid when used with the /C option.  
  181.  
  182.  
  183.  
  184. /R-levels
  185.  
  186.       Scan the directory tree recursively down to 'levels' levels deep.  If
  187. 'levels' is not specified, DIFF will scan all levels 'under' the starting
  188. directory level.
  189.  
  190.       For example, if your directory tree looked like this:
  191.  
  192.       C:\
  193.       ├─── UTIL
  194.       │    └─── MISC
  195.       └─── WP51
  196.            ├─── DOC
  197.            └─── GRAPHICS
  198.  
  199.     ■ without /R ■ would include only the root directory (C:\).
  200.     ■ /R-1 ■ would include the directories C:\, C:\UTIL\, and C:\WP51\.
  201.     ■ /R ■ would include all of the directories.
  202.     ■ /R-2 ■ would do the same thing as /R in this case since the deepest
  203.       directory is only 2 levels deep.
  204.  
  205.       You can also use /R to process only a specific branch of the directory
  206. tree.  If you had specified:
  207.  
  208.       DIFF /M /R C:\WP51\
  209.  
  210.       DIFF would have processed the directories C:\WP51\, C:\WP51\DOC\, and
  211. C:\WP51\GRAPHICS.
  212.  
  213.       Note:  Using this option on a large network drive can take quite a
  214. while.  Since it may not look like it is doing anything, you may think your
  215. machine has 'hung', but be patient, it does work.
  216.  
  217.  
  218.  
  219. /S
  220.  
  221.       Screen display.  If this option is specified, DIFF will echo all data to
  222. the screen as well as to the Difference file (if one is being created).
  223.  
  224.       Pressing any key while DIFF is displaying changed file information on
  225. the screen will either stop screen display (turn off the /S option), or abort
  226. the program (if /N was specified).  This can be useful when you are running
  227. DIFF with a batch file that uses the /S option but you don't need (or want) to
  228. see all of the information on the screen.
  229.  
  230.       This option is only valid when used with the /C option.
  231.  
  232.  
  233.  
  234. /N
  235.  
  236.       No Difference file.  If this option is specified, DIFF will not create a
  237. Difference file.
  238.  
  239.       This option automatically sets the /S option.
  240.  
  241.       This option is only valid when used with the /C option.
  242.  
  243.  
  244.  
  245. /U
  246.  
  247.       Include unchanged files.  If this option is specified, DIFF will include
  248. unchanged files in the Difference file (or display).  Normally DIFF only
  249. reports the files which have changed since the last Benchmark was created. 
  250. This option will allow DIFF to display ALL files.
  251.  
  252.       This option is only valid when used with the /C option.
  253.  
  254.  
  255.  
  256. /O
  257.  
  258.       Overwrite Benchmark file.  If this option is specified, DIFF will
  259. automatically overwrite an existing Benchmark file when creating a new
  260. Benchmark.  The default is not to overwrite an existing file.
  261.  
  262.       This option is only valid when used with the /M option.
  263.  
  264.  
  265.  
  266. /A
  267.  
  268.       Append to Benchmark or Difference file.  If this option is specified,
  269. DIFF will append all information that it produces to an existing Benchmark or
  270. Difference file.  If the file does not exist, it will be created.  For
  271. example, this option could be used when you want your Difference file to be a
  272. revision history of each time that the files have (or have not) changed.
  273.  
  274.  
  275.  
  276. /H
  277.  
  278.       Help.  If this option is specified (anywhere) on the command line, DIFF
  279. will display its help screen and then exit.
  280.  
  281.  
  282.  
  283. path
  284.  
  285.       The path to begin working on.  If included, the path MUST end with the
  286. backslash character ('\').  If it does not end in a backslash character (e.g.
  287. 'C:\UTIL'), DIFF will use the intended directory name as a part of the
  288. 'filespec' parameter (see below).  In the example, instead of using
  289. 'C:\UTIL\*.*' (as intended) DIFF would use 'C:\UTIL.*' and would only check
  290. the files named 'UTIL.*' in the root directory of drive C:.  
  291.  
  292.  
  293.  
  294. filespec
  295.  
  296.       The filename mask to use when searching for files.  This can include the
  297. wildcard characters '*' and '?.'  If a filename or an extension is not
  298. supplied (e.g. "TEST" or ".DOC" or nothing at all), the wildcard '*' will be
  299. supplied automatically and the examples would become "TEST.*", "*.DOC", and
  300. "*.*" respectively.
  301.  
  302.  
  303.  
  304. Errorlevels returned to DOS
  305.  
  306.       When used with the /C option, DIFF will return an errorlevel to DOS (for
  307. use in batch files) indicating how many differences it found when comparing
  308. files.  If the number of differences exceeds 250, it will return an errorlevel
  309. of 255 (the maximum allowed by DOS).  This was to allow for the following
  310. error messages to be reported via errorlevel.
  311.  
  312.       DIFF will return the following error codes under the listed circumstanc-
  313. es.
  314.  
  315.     251  ■  Couldn't open Benchmark file.
  316.     252  ■  Couldn't open Difference file.
  317.     253  ■  Help was requested on the command line.
  318.     254  ■  DIFF couldn't find anything useful to do.  Most likely, /C or /M
  319.             was not specified.
  320.  
  321.  
  322.       The following segment of text is a batch file that controls what happens
  323. when there are errors or certain numbers of differences.
  324.  
  325.       diff /c-c:\log\diff.Log /d-c:\log\diff.dif /r c:\
  326.       if errorlevel 255 goto lots
  327.       if errorlevel 251 goto error
  328.       if errorlevel 11 goto some
  329.       if errorlevel 1 goto few
  330.       
  331.       :none
  332.       echo There were No Differences.
  333.       goto end
  334.       
  335.       :lots
  336.       echo There were Lots of differences (more than 250).
  337.       goto end
  338.       
  339.       :some
  340.       echo There were Some differences (between 11 and 250).
  341.       goto end
  342.       
  343.       :few
  344.       echo There were a Few differences (between 1 and 10).
  345.       goto end
  346.       
  347.       :error
  348.       echo There was an error running DIFF (don't know what kind).
  349.       
  350.       :end
  351.       echo Done!
  352.  
  353.       Note the order in which errorlevels are checked.  When DOS sets an
  354. errorlevel, all lower errorlevels become true.  In other words, if DOS sets
  355. the errorlevel to 100, then 99, 98, and everything down to 0 is set as well. 
  356. For this reason, you must check the highest errorlevels first, and work your
  357. way down to the lower error levels.
  358.  
  359.       When used with the /M option, DIFF will return the following
  360. errorlevels.
  361.  
  362.       0  ■  Successful in creating the Benchmark file.
  363.       1  ■  Terminated because the Benchmark file existed and /O or /A was not
  364.             specified.
  365.     251  ■  Couldn't open Benchmark file.
  366.     253  ■  Help was requested on the command line.
  367.     254  ■  DIFF couldn't find anything useful to do.  Most likely, /C or /M
  368.             was not specified.
  369.  
  370.  
  371.  
  372. A Little Trick
  373.  
  374.       If you use DIFF to check your entire Hard Drive, you will find that it
  375. will always report that the Benchmark file, and sometimes the Difference file
  376. have been changed since the last run.  In order to get around this, you can
  377. create a hidden directory where DIFF does not check files for differences.  If
  378. you store your Benchmark and your Difference files in a hidden directory, they
  379. will not be checked for differences when scanning your entire drive.  You will
  380. be able to see if someone has created or deleted a hidden directory, but not
  381. if they have made changes to the files within that directory.
  382.  
  383.       To create a hidden directory requires a specialized utility.  Normal DOS
  384. will not allow you to create a hidden directory.  I use DirMagic on my system,
  385. although many others will work just as well.
  386.  
  387.  
  388.  
  389. Specifications
  390.       DIFF:
  391.  
  392.     ■ was written, compiled, and linked with Turbo C++ by Borland
  393.     ■ was packed with EXEPACK version 4.00 by Microsoft and TINYPROG by
  394.             Tranzoa, Co.
  395.     ■ was developed under DOS 4.01
  396.     ■ has been tested with Novell Netware up through version 386 3.0
  397.     ■ will support up to 2500 files per directory (maximum due to memory
  398.             limitations)
  399.     ■ will support up to 3000 directories on a single volume (hard disk)
  400.     ■ requires approximately 170K bytes of RAM to run
  401.     ■ was designed with command line or batch file operation in mind
  402.     ■ is free and I don't expect anyhing except enhancements or bug reports.
  403.     ■ will be updated if bugs are found or enhancement requests are received
  404.             and implemented.
  405.  
  406.  
  407.  
  408. Examples
  409.       Here are a few ways that I have found DIFF can be used.  If you think
  410. your way of using DIFF could be widely used, let me know so I can document it
  411. here.
  412.  
  413.  
  414.  
  415. Document Management System
  416.  
  417.       This is a very simple use of DIFF.  It allows many people to make
  418. changes to a group of documents in a given directory and allows you to check
  419. the directory periodically to see if any of the documents have been updated in
  420. case they need to be printed, or otherwise processed.
  421.  
  422.       To make the Benchmark, be logged to the directory containing the
  423. documents that you want to check and type the command:
  424.  
  425.       DIFF /M /O
  426.  
  427.       To check the Benchmark, be logged to the directory containing the
  428. documents that you want to check and type the command:
  429.  
  430.       DIFF /C /S
  431.  
  432.       The results of these two steps will be a file named DIFF.DIF in the
  433. directory where the documents reside as well as the display on the screen of
  434. the documents that have been changed.
  435.  
  436.  
  437.  
  438. Crude Security System
  439.  
  440.       
  441.       This is one way to make a Benchmark of, and later check, your entire
  442. hard drive.  This is a sort of crude security system that doesn't stop anyone
  443. from making changes to your system, but does tell you what has been changed.
  444.  
  445.       First, to make the Benchmark, you may be logged to any drive or any
  446. directory you choose.  then type the command:
  447.  
  448.       DIFF /M-C:\DRIVEC.LOG /O /R C:\
  449.  
  450.       DIFF will create a Benchmark file named DRIVEC.LOG in the root directory
  451. of drive C:.  If a file with that name already existed, DIFF will overwrite
  452. it.  DIFF will start in the root directory of drive C: and will process all of
  453. the directories on the entire drive logging all file to DRIVEC.LOG as it goes.
  454.  
  455.  
  456.       Second, to check the entire hard drive against the Benchmark you may be
  457. logged to any drive or directory on your system and type the command:
  458.  
  459.       DIFF /C-C:\DRIVEC.LOG C:\ /D-C:\DRIVEC.DIF /R
  460.  
  461.       DIFF will look for an file in the root directory of drive C: named
  462. DRIVEC.LOG.  It will then use this file to compare all directories on drive C:
  463. (starting at the root directory) and log any differences to DRIVEC.DIF in the
  464. root directory of drive C:.  The final results of these two commands will be a
  465. file named C:\DRIVEC.DIF which will contain a list of files that had changed
  466. between the time you made the Benchmark and the time you checked it.
  467.  
  468.  
  469.  
  470. Enjoy!
  471.       If you have any questions, enhancements or bug reports, please feel free
  472. to contact me at:
  473.  
  474.       Doug McKay
  475.       294 East Nineta Circle
  476.       Orem, UT  84057-4703
  477.       (801) 224-7288
  478.  
  479.