CTT - Compare Tree&Text for Windows — V1.10
(C) 1991-2024 Giuliano Artico

SUMMARY

0. Introduction

ctt.exe is a command-line utility designed to compare one or more files contained in a given directory with files contained in a target directory. The program runs in console mode under any version of Windows XP/Win7/Win10 and later, both 32-bit and 64-bit.

The program supports two operative modes as follows.

Tree compare mode or «Tree Mode» for short
Purpose: quickly compare files in a directory and its subdirectories and delete some of them with various criteria if desired, e.g. to check/purge a backup. In this mode, the program can also calculate the coherence between the compared files and optionally record the details of the coincidences and discrepancies for the file pairs that give comparison error.
Text compare mode or «Text Mode» for short
Purpose: compare a single source file with a target file by lines or by blocks and display differences. Here the behavior is interactive.
Run the program at the Windows prompt with the following general syntax:
ctt.exe SourceSpec TargetSpec [options] [<OptFile]
The parameters SourceSpec and TargetSpec are mandatory in Tree Mode and optional in Text Mode. The choice of either operative mode is automatically determined by specification SourceSpec.
All options may be specified with the CTT_OPT environment variable or redirecting a file containing the desired options to standard input.
Options are specific for each mode (see later).
Results are shown on the console and may be optionally logged into a report file.
Some additional tasks are available to go to the processing results, to open the manual and to open particular folders, see the /G option.

0.1. Fast completion of file specifications with /F option

The /F option, which stands for Fast, is common to tree and Text Mode and aims to simplify the entry of names for comparing individual files.
If you use this option, file specifications will be treated differently than usual: the program will attempt to complete the given specifications with the names of two existing files that correspond to them and will carry out the comparison between these individual files. With the /F option, TargetSpec is allowed to include wildcards.

If TargetSpec is omitted or if there is no file that matches it, the target file will be searched among those that match SourceSpec

Just as an example, you could copy two files you want to compare into an empty directory and run the simple command ctt * /f. For other examples, see [1.6].

Back to summary.

1. Tree compare mode

The program will execute in Tree Mode if either the parameter SourceSpec is a folder/drive or contains a wildcard character («*/?»). However, if SourceSpec matches a single file in the given directory, the Text Mode will be selected instead. Anyway you may force the Tree Mode execution by specifying the /TR option.
Note. if the executable file is renamed as ct.exe, then all the features of the Text Mode are hidden and the program is in effect a complete emulation of CompTree [6].
The files corresponding to SourceSpec may be located in all subdirectories or in those down to a specified depth (see option /S).
TargetSpec is usually a drive or directory and files in SourceSpec will be compared to the ones in TargetSpec with the same name, respecting the tree structure for those contained in subdirectories.

TargetSpec may also be a single file: in this case all files in SourceSpec will be compared to it; however, it cannot contain wildcards or be a directory, except in the special case in which the /F option is specified [0.1].

1.1. Command line options for Tree Mode

In the following option list, the differences with respect to CompTree [6] are marked with [New]. See also the remarks in [3].
/S[n]
Include subdirectories of SourceSpec in the source scan and compare files there to the files in identical TargetSpec subdirectories.
[New] If an optional number n is specified, only the subdirectories down to level n are considered. E.G., /S1 will include files in the given directory and in all subdirectories at first level.
Use /S without any parameters to consider all subdirectories.
Use /S0 or /S- to restore the default setting (no subdirectories).
/D[...][:backupdir]
This option has several modifiers that can be used to delete source files, subject to the result of comparison.
  • /D (without any parameters): delete source files and subdirectories that match.
  • /DF: delete only files (i.e., even if a subfolder remains empty, it is kept).
  • /DB: delete also base directory (provided it remains empty and it is not the current directory).
[New] The following modifiers of the option /D where not supported in CompTree.
  • /D!D: delete source file if source and target have different sizes.
  • /D!E: delete source file if any error occurs (compare, size, open).
  • /D!M: delete source file if the corresponding one is missing in target.
  • /D!A: delete source file if match fails, same as /D!D!E!M.
  • /DR: don't delete read-only files
  • /DH: don't delete hidden files
  • /DS: don't delete system files
Most modifiers may be combined, e.g. /D!MHS deletes files that are missing in target, but don't delete those of them that are hidden or system.
The modifiers !A, !D, !E, !M may cause unrecoverable loss of data! Therefore, if one or more of them are specified, the program copies the deleted files into a new subfolder of an appropriate backup folder (see [3]).
You may assign the backup folder with the modifier :backupdir. E.g., if you specify /D!A:D:\backup, all deleted files will be copied to a new subdirectory CT0001, CT0002,... of D:\backup, replicating the subdirectory structure . The :backupdir token must be the last specified parameter, to the right of other possible modifiers.
The default backup folder may vary, depending on the program folder and Windows version (see [3], remark 8).
If you don't want to backup delete files, specify :nul as a backup directory, e.g. /D!M:nul.
Use /D- to restore the default setting (don't delete any files).
/L[...][:logfile]
Store results in a file report. This option has several modifiers, as described below.
  • logfile: name of the report file. By default, the results are appended to the existing file. The default file name is either ctt.log or ct.log,depending on the name of the executable file.
  • O: Overwrite existing report file.
  • C: log file when compare fails (including files with different sizes).
  • F: log file when open or read fails (File error).
  • M: log file when target is missing.
  • E: Log file if any error occurs (including read and open, but not missing target).
  • A: log all non-ok results (same as /LME).
  • K: log file when compare is successful.
  • R: log results too (OK, Target not found, Different file sizes, Compare error): in fact, when C, F, M, E, A or K is used, only source filenames are logged by default, no compare results.
  • Q: use quotes around file names containing spaces.
  • Q2: use quotes around all file names.
  • B: [New] write a bare list of files in the report, omitting the header and summary.
  • P: [New] add full path to file names.
  • Use /L- to restore default (report logging disabled).
Options can be combined, for example
/LOK:logfile
to log successfully compared files to logfile, which is overwritten if it exists. Adding R to the command causes results to be logged too.
Note. Some modifiers together don't make much sense: for example, /LAKR and /L are equivalent.
/N
No summary at end. This is the default behavior when a single file is specified.
Use /N- to restore the default setting.
/Q
Quick mode: assume that same size equals same contents.
With /Q2, the files are assumed to be identical provided they have both the same size and the same timestamp (last write access).
Use /Q- to restore default (byte-by-byte comparison for files with the same size).
/ON
No screen output. Only the progress of the process is displayed if console mode is selected (/C option).
Use /O- to restore the default setting.
/B[...]
Beep when finished. The following characters may be added to /B to get the effects described below.
  • No character or 1: play a short single-tone beep-.
  • 2: play a more arcade-like beep (this may be less suitable for an office environment).
  • R: play a beep determined according to the result of comparison, namely a rising tone for no errors, a falling tone otherwise.
  • K: beep only when no errors occurred.
  • [New] C: beep only when at least one compare error occurred.
  • [New] M: beep only when at least one file missing in target is found.
  • A: beep only when any error occurred.
Whenever it makes sense, the modifiers may be combined, e.g. /B2RK.
The modifiers K, C, M, A should be used separately, but if two or more of them are specified, they are applied in this order with decreasing precedence.
Use /B- to restore the default setting (no beep).
/C
Console mode: show results in bottom line.
With /C2, the percentage is also shown (based upon number of processed files).
Use /C- to restore full display.
/E[ExtList]
[New] ExtList denotes a list of space-separated extensions in which the period is optional, for example it makes no difference to indicate txt or .txt. The only case in which the dot is mandatory is the "." extension, consisting of a single dot, which corresponds to files that have no extension. If you specify a single hyphen «-» as the list, you set the following default list:
. txt bat htm html m3u vbs xhtml xml adi asc bas bib c cmd css csv edi h ini log lst ly mak pas php pl sh shtm shtml tex
To specify the .- extension, add other extensions or include the leading dot. The /E option without parameters clears the list, i.e. no files will be treated as text files.
Example:
/E txt htm . log
/F[-]
[New] This option aims to simplify the entry of names for comparing individual files, for details see [0.1].
/G[-]|[B][D][L]|[A]|[M][U][V][W]
[New] The /G option is used to go to the results obtained when the program finishes the requested processing and to perform some additional tasks. The following modifiers can be used.
  • L: Go to the report log, same as the G modifier in the /L option.
  • B: Go to the backup folder, same as the G modifier in the /D option.
  • D: Go to the coherence detail folder, same as the G modifier in the Choice parameter of the /P option.
  • A: Same as BDL.
With the following modifiers the indicated action is carried out without performing any processing.
  • M: Open the local or remote manual, like the /MAN option.
  • U: Open the user's local settings folder.
  • V: Check the latest version of the program, like the /VER option.
  • W: Open the work folder.
Use/G- to override any modifiers set with another instance of the /G option.
/Mn[L]
[New] n denotes an integer number between 1 and 10000 with default value 100 that represents the maximum allowed amount of memory expressed in MB [1.3]. In the coherence calculation, if the modifier L is appended after the number n, only the largest file will be loaded into memory: This will slow down processing by approximately 3 percent.
/P[CharList][,[Mesh][,Choice[,Savepath]]]
[New] The letter P stands for percentage and reminds you that with this option the coherence calculation is activated in any pair of files for which a comparison error has occurred.
  • CharList is a string of case-insensitive alphabetic characters no less than 10 in length.
    The exclamation point character ! is an abbreviation for all consonants, while the double exclamation point !! denotes consonants except CDNSYZ.
    If the list is empty, the string of all letters is assumed.
  • Mesh denotes an integer number between 0 and 1024, with a default value of 5, that determines the width of the grid for coherence calculation. The parameter expresses the block length in multiples of 16 bytes, so that it can vary between 16 and 16384 bytes.
  • Choice denotes a string that contains at least one of the letters S, C, or L. Depending on the letters you choose, the portions of the files being compared that match or are present in only one of the files will be recorded in specific files. See more details in [1.4].
    If the Choice parameter is not left blank, coherence calculation for all files is performed without normalization, as for binary files.
  • SavePath indicates the folder to host the detail files that are produced when the Choice parameter is specified. This must be a plain name without path and its default value is split. The folder is created if it does not exist and is entirely emptied when it contains any files or subfolders.
/V[n]
[New] Set the sound volume as a percentage, where n indicates a number in the range 0 to 100. Specify 0 to suppress all sounds.
Use /V without any parameters to restore the default value 20.
This option is common to Text Mode.
help options
  • /? or /H: display a summary of the available options.
    Note. If the executable file name is other than ct.exe, use the /?? option instead (since in this case /? refers to the Text Mode).
  • [new] /MAN: open the ctt.htm manual if the file is in the program folder, otherwise open the on-line manual.
  • [new] /VER: checks the latest version of the program and allows you to download it.
  • /LOG?: displays logging options.
  • /B?: displays beep options.
  • /ERR?: displays DOS errorlevels.
  • /DEL?: displays details for /D option.
  • [new] /P?: displays details for /P option.
[New] The output of help screens can be redirected to a file.

1.2. System folder protection

The Windows and program folders (32 and 64 bit) are protected against writing and file deletion. More precisely:
  1. the /D option is disabled if SourceSpec indicates files in these directories or their subdirectories.
  2. it will not be possible to write the log to these directories (/L option) and not even assign a backup folder for deleted files inside them (/D option).

To change this behavior, you can assign a list of protected folders with the /$SYSPROTECT option as follows:

/$SYSPROTECT:[*;]folder1;folder2;...
where the «*» element is an abbreviation in place of c:\Windows;C:\Program Files;C:\Program Files (x86).
CAUTION! This feature can be harmful: it must be used with extreme attention and awareness.

1.3. Coherence (C) and size ratio (R)

When a comparison error occurs for a pair of files or if they have different sizes, one may ask whether it is possible to estimate a global measure of the difference between the two files. The program provides an answer to this question by offering the possibility of calculating a degree of coherence between the files being compared: the coherence C is a percentage value that is closer to 100 the greater the similarity. The process is skipped when the two files are identical (in this case, it is understood that C is implicitly 100%).

When carrying out the coherence calculation, it is also possible to store in special files the pieces of text in common or those that fall outside the intersection

To calculate the value C, specify the /P option at the prompt. The calculation is carried out differently depending on the type of files. Files are considered text when their extension is included in a specific list, which by default consists of the most common text file extensions. The list is user configurable with the /E option.

Case 1: both files being compared are text files.
C is calculated by ignoring non-alphabetic characters and case differences. Furthermore, accented characters are normalized by considering the corresponding non-accented characters in their place.
You can refine the calculation by taking into account only a particular list of characters to be specified (see the CharList parameter of the /P option). The resulting value of C may vary depending on the character set used. By default, all alphabetic characters are used.
Case 2: at least one of the two files is not a text file or binary comparison is forced.
C is determined by faithfully loading the contents of the files without any alteration.
In the first case, the two files being compared are entirely loaded into memory, so that the sum of the two file sizes must not exceed the maximum memory allowed, whereas in the second case, only the larger file is loaded. By default, the maximum memory allowed is 100 Mb and is configurable with the /M option.

Warning. Please note that in the case of large files the calculation can take quite a long time. You can press the Esc key to skip the calculation for the current file.

The size ratio R between the files is also calculated, expressed as a percentage of the smaller file compared to the larger one. In the result displayed on the screen, the values of C and R are added next to the file name as in the following examples.

source.exe & target.exe Different file sizes|B,C=26.69%,R=93.99%
source.txt & target.txt Different file sizes|T,C=94.02%,R=71.67%
Where: The same pattern is reported to the log if the R modifier of /L option is specified.

1.3.1. Important note on interpretation of coherence results

. It can happen that two files of very different sizes have a coherence close to or even equal to 100%. This happens for example when the smaller file is entirely contained in the larger file. To correctly interpret coherence, it is therefore important to also take the size ratio into consideration. In practice, if both the C and R values are close to 100%, it can be said that the two files are very similar to each other. However, if C is close to 100% but R is low, it is possible that the smaller file is simply a portion of the other.

1.4. Detailed reports regarding coherence

When the coherence calculation is applied, the Choice parameter of the /P option can be assigned one or more letters to allows the storage of detailed information in specific log files. You can get the portions of text that the files being compared have in common or those that fall outside the intersection. Just as an example, these details could be useful to detect changes made in different editions of a program source.

All log file names replicate the name of the source file with the addition of the .dat extension. furthermore, log names will be prefixed by one of the letters S, C, or L, as follows.

  1. Remainder of smaller file, letter S.
    Store the blocks of the smaller file that have not a match in the larger one.
  2. Coincidences, letter C.
    Store the blocks which are identical in both files.
  3. Remainder of larger file, letter L.
    Store the blocks of the larger file that are not matched in the smaller one.
  4. Full details, letter A.
    To obtain maximum detail by recording all the logs, specify all three letters S, C, and L, or just indicate the letter A, which stands for All.
    Example. The /P,,SCL and /P,,A options are equivalent.
Remarks.

1.4.1. Outline of the method used to calculate coherence

The coherence is calculated by dividing the smaller file into blocks and checking how many of these blocks are contained in the other file, applying normalization if both files are text.

Within certain limits, as the mesh value decreases, the accuracy of the coherence calculation and details in S and C log files improve, even if this comes at the cost of a reduction in processing speed.

On the other hand, the details in the L log files are less accurate if the mesh parameter has a low value. In this case, in fact, there is the possibility for some blocks to obtain multiple matches: all the strings found in an unexpected position give rise to false positives, thus altering the reconstruction of data. The possibility of multiple matches is reduced by increasing the mesh, i.e. by adopting a coarser grain.
Generally the best compromise is a mesh value between 5 and 10, although it may make sense to choose different values depending on the content of the files.

1.5. Errorlevels

The following errorlevel codes are returned by ctt.exe at the end of the execution and are the same as released by CompTree [6]. Errorlevel codes can be read by batch files using the ERRORLEVEL variable. This way, a batch-file can automatically decide what to do after comparing two files.

1.6. Examples for Tree Mode

  1. Compare the entire tree of files in dir1 with those in dir2 and write the results in the file d:\txt\ct-log.txt, overwriting it if it already exists:
    ctt dir1 dir2 /s /lo:d:\txt\ct-log.txt
    
  2. Same as above, but deleting all files in dir1 that are identical to the corresponding in dir2 and also removing the directory dir1 if it will turn out that it is empty at the end of the process:
    ctt dir1 dir2 /s /db /lo:d:\txt\ct-log.txt
    
  3. The following command performs a process that is complementary to that of example 2, in the sense that it keeps all the files in the subtree of dir1 that are also present in the folder dir2, while it moves all files with missing target into a subdirectory of d:\backup. The name of this subdirectory is the first among ct0001, ct0002,,... that does not yet exist.
    ctt dir1 dir2 /s /l /d!m:d:\backup
    
    Note. You may use a different modifier. For example, /D!a will delete and move files when they are missing in the target folder or give compare error or have different size, keeping those that match exactly.
  4. Unlike example 1, here the modifiers of the /L option allow you to list only the files that match, so that the list produced can be used later to create a RAR archive that contains them. To be precise, these are the modifiers used:
    • «K» lists the files that match,
    • «B» produces a bare list of files (no headings, no summaries),
    • «P» includes the full path in file names.
    ctt dir1 dir2 /s /l O K B P :d:\txt\ct-log.txt
    rar a archive.rar @d:\txt\ct-log.txt
    
  5. compare the *.txt files in c:\files and its subfolders with the corresponding ones in d:\TargetDir, activate the coherence calculation with blocks of 7*16=112 bytes, save the execution log and all the coherence details and when finished view the log and open the details folder:
    ctt c:\files\*.txt d:\TargetDir /S /L ao /P,7,a /G dl
    
  6. The next table shows some example commands including the /F option with possible source and target files that match the given specifications [0.1]. These examples are valid for both Text Mode and Tree Mode.
    COMMAND LINE SOURCE TARGET
    ctt m*.txt c*.txt /f mouse.txt cat.txt
    ctt d:\somedir\a* e:\more\b* /f d:\somedir\apricot.txt e:\more\banana.txt
    ctt d:\fruits\ /f d:\fruits\apple.txt d:\fruits\cherry.htm

Back to summary.

2. Text compare mode

This part is derived by a small program that I wrote for my personal use in the Nineties to locate changes in different versions of source programs (.BAT, .TEX, .pl, .php, .htm, etc.).

The program compares two text files, respectively called Source and Target, proceeding line by line and stopping when it identifies a pair of lines,in the first and in the second file, that are different from each other. If this happens, a portion of each line is displayed to highlight the differences.

If the file is binary, the scrolling occurs instead in blocks, applying the commands described below for the lines to them too. The default block size is 60 bytes, but you can specify a different block length with the /R option.

If necessary, we will refer to the two situations by speaking respectively of comparison by lines and comparison by blocks

The syntax for Text Mode is as follows:

ctt.exe [sourcefile [targetspec ]] [options]
If either file specification is missing, the program will prompt to enter them.

When the program stops to display differences, you can press several keys as described in the list below.

F1
Display the list of available keystrokes.
Arrow keys, Ctrl+Left/Right, Ctrl+PgUp/PgDn
Move the cursor on the screen (this can be useful for screen reader users to carefully inspect text).
F1
Display a keystroke summary.
F2/Shift+F2
Move the cursor right/left to the next character with a different color attribute, that is,to the point where the differences begin.
Return, Space, PgDn
Find the next pair of different lines, by moving forward.
Backspace, PgUp
Find the next pair of different lines, by moving backwards.
Tab
Advance one line in both files.
Shift+Tab
Go back one line in both files.
Lowercase «s», «1», F5
Advance one line in Source.
Lowercase «t», «2», F6
Advance one line in Target.
Uppercase «S», «3», Shift+F5
Go back one line in Source.
Uppercase «T», «4», Shift+F6
Go back one line in Target.
F7/Shift+F7
Jump to last/first marked pair of lines.
F8/Shift+F8
Jump to next/previous marked pair of lines.
F9
Mark the displayed pair of lines shown last, to be able to easily return to that point (see F7/Shift+F7, F8/Shift+F8).
F10
Jump to specific lines. After pressing F10, you may type:
  • a line number to jump to that line in both files, or
  • two numbers separated by «/» to jump to the lines corresponding to the two numbers in Source and Target respectively.
F11
Open the ctt.htm manual if the file exists in the program folder, otherwise open the on-line manual.
F12
Checks the latest version of the program and allows you to download it.
Ctrl+Home/End
Jump to the first/last line in both files.
End of session
Press Esc or Alt+F4 to terminate the comparison. The program displays a summary and prompts to exit. You may press Y to exit, N to start again with a new pair of files, or Esc to recover the current session at the last displayed line.
To identify text files, a slower but more accurate mechanism is used here than that of the extension-based Tree Mode, since in this case we only need to examine two files. In practice, the program analyzes an initial segment of the file and assumes that it is binary, i.e. not text, if it finds control characters (ASCII code less than 32) that fall into a given list (see the /X option).

2.1. Command line options for Text Mode

See the remarks in [3].
/A[f1][,f2]
f1 and f2 denote two numbers to set the frequencies of the tones for sound highlighting of color attributes on screen. The default frequencies are 1024 and 1367, corresponding to the notes C and F of the fifth octave of piano.
Use /A- to restore the default values.
/F[-]
This option aims to simplify the entry of names for comparing individual files, for details see [0.1].
/G[-]|[L]|[M][U][V][W]
Similar to the /G option for Tree Mode, with the exception of the modifiers B, D, A, which in this case make no sense.
/I
ignore capitalization when comparing files by lines. Use /I- to restore default (case sensitive comparison).
/L[O][:logfile]
Store results in a file. The default name of the report is ctt.log. You may specify a different name by adding a colon and the file specification.
You may add the optional modifier «O» to overwrite the report file, if it already exists.
Use /L- to restore default (report logging disabled).
/N[P]
No keyboard action. The program does the processing without displaying differences. This option should be used together with the /L option.
/NP prevents the program from prompting for a new operation at end.
Use /N- to restore default displaying.
/R[n]
n specifies the block size in bytes for binary comparison: it can range from 1 to 4096.
Use /R without any parameters to restore the default value of 60.
/TR|X[B][,n]
Force the choice of the operating mode by specifying one of the modifiers listed below.
  • /TR: force start in Tree Mode, even for a single file.
  • /TX: force start in Text Mode.
  • /TXB: force comparison by blocks even for text files.
  • The optional number n indicates the file size of Sourcefile in megabytes and defines a threshold above which files will be compared in Tree Mode. However, if the «X» modifier is present, it takes precedence and even with files that exceed the threshold the Text Mode comes into operation.
    The default threshold value is 10.
  • Use /T- to restore the default settings.
/V[n]
(This option is common to Tree Mode.) Set the sound volume as a percentage, where n indicates a number in the range 0 to 100. Specify 0 to suppress all sounds.
Use /V without any parameters to restore the default value 20.
/W[n]
ignore characters in comparison. The modifiers listed below are available.
  • 0: plain comparison, no character wil be ignored.
  • 1 (or no parameter): ignore blanks at end of lines (default).
  • 2: ignore blanks at begin of lines.
  • 3: ignore blanks at begin and end of lines.
  • 4: ignore all characters in the CharList defined with the /Y option
/Xcharlist
Set the list of control characters that are not allowed in text files, used to identify binary files.
charlist is a comma-separated list of numbers in the range 0-31. You can specify a sequence of contiguous numbers with the abbreviation m-n, e.g. /X0-8,14-31.
The default list is: 0-6,14-25,27-31.
Use /X without any parameters or /X- to restore the default list.
Note. Characters 10 and 13 will be never included in this list. For the remaining characters, it is the user's responsibility to indicate a proper character list.
/Ycharlist
Set the characters to ignore when comparing text files by lines.
charlist is a comma-separated list of numbers in the range 0-32. You can specify a sequence of contiguous numbers with the abbreviation m-n, e.g. /Y9-13,26
Default list: 9,12,13,32.
Use /Y without any parameters or /Y- to restore the default list.
Help options
  • /? or /H: display a summary of the available options.
  • /??: summary of options for the Tree Mode.
  • /MAN: open the ctt.htm manual if the file is in the program folder, otherwise open the on-line manual.
  • /VER: checks the latest version of the program and allows you to download it.
The output of these screens can be redirected to a file.
The options /I, /W, /X are ignored when comparison by blocks is selected.

2.2. Remarks about Text Mode

The following remarks apply to Text Mode only. Remark. The comparison method adopted by CTT in Text Mode may appear rudimentary to a sighted user. Unfortunately, the most effective tools, such as the PSPad text comparator, are not friendly to blind users, who interact with the PC through a screen reader. I want to hope that the Text Mode of this application can still be of benefit to someone, as it has been for myself.

Back to summary.

3. General remarks

The remarks in this section apply both to Tree Mode and to Text Mode.
  1. An option consists of a slash immediately followed by a case-independent letter and a string containing the parameters for that option.
  2. You can specify any option with the CTT_OPT environment variable.
  3. You can also write options to a file and redirect its contents via standard input (stdin).
  4. Options are acquired with minimum priority from the environment variable, intermediate from stdin and maximum from the command line.
  5. An arbitrary number of options can be specified. If an option is repeated, the last instance applies, whatever the input channel, even when the repetition takes place in the same line.
  6. A file bein redirected via stdin must start with the string [ctt] and is processed line by line. Lines starting with the hash character «#» are treated as comments and are ignored.
  7. For most options, the default settings can be restored at command line by the option followed by a minus sign. This can be useful, for example, to override another instance of the same option that was set with the CTT_OPT environment variable or via standard input. See more details in [1].1 and ([2].1.
    Example. You may set a fixed name for the report file in the CTT_OPT environment variable:
    set ctt_opt=/l:d:\somedir\somefile.txt
    
    and later you can simply use /L- to disable report logging or /LO to overwrite the report in the file d:\somedir\somefile.txt.
  8. Here is the default list of folders, in order of decreasing precedence, in which the program will write the report (/L option) and, in Tree Mode, will place backup copies of deleted files (/D option) and detailed reports regarding coherence (/P option):
    • the current directory;
    • the directory of the program executable file;
    • the subdirectory CT in the user's local settings folder;
    • the directories listed in the TEMP environment variable;
    • the system temporary directory.
    However, note that the backup directory and the coherence reports will never be placed in any subdirectory of the source file directory (see the /D option with modifiers !a, !D, !E, !M and the parameter Choice in the /P option).
  9. when a process takes a longer time, a rhythmic clicking sound is emitted. The volume of this tick if fixed and cannot be adjusted. Use the /V0 option to suppress it.

Back to summary.

4. Notes for CompTree users

If you are familiar with CompTree [6], you can rename the executable file as ct.exe. This way, you can use exactly the same commands you were used to. You can continue to use your old batch files because all options, errorlevel codes, logging features and beeps have been preserved.

The new features and additions are sumarized below (see more details in [1]).

/B option
New C and M modifiers.
/D option
New !A, !D, !E, !M, R, H and S modifiers.
The !A, !D, !E, !M modifiers allow to delete files that don't match. In this case , deleted files are saved in a backup directory, that can be assigned with the :backupdir modifier.
/L option
New B and P modifiers.
Some new information in the log header (free memory during process, command line, environment variable if set, list of protected folders) and in the summary (compare speed).
/S option
A new optional numeric parameter allows to specify the depth of subdirectory to limit file scanning.
The following new features are also available.
New options /F, /G, /M, /P, /V, /MAN, /VER
For details on these new options see [1.1].
Invalid options are ignored
If you specify an invalid option, the program simply ignores it and gives no error messages. Most options have a modifier to restore default values.
Environment variable
All options can be included in the CTT_OPTd environment variable.
Specify options via standard input
You can write options to a file and redirect its contents via standard input (stdin).
System folder protection and /$SYSPROTECT option
The Windows and program directories are protected against writing and file deletion.
The /$SYSPROTECT option can be used to set protection for more directories.
Reserved or invalid file names
Terms as PRN, LPT1, etc., are not accepted in file names or path.
If a report file or backup directory contains such an element, the default is assumed. The same applies if the file specification is not syntactically valid.
Output redirection
added support of output screen redirection (for help screen only).
Fixed file size limitation
The comparison works correctly even on files larger than 2 Gb.

Back to summary.

5. License

The CTT program can be used and distributed free of charge. Nobody is authorized to ask for compensation for the supply, for the installation, for the use or in any case for any service concerning this software.
The CTT program is distributed "as is". No warranty of any kind is expressed or implied. You use at your own risk. The author and his associates will not be liable for data loss, damages, loss of profits or any other kind of loss while using or misusing this software.

5.1. Download

The program is distributed as a ZIP compressed archive that contains the executable file ctt.exe and this manual ctt.htm.
After unpacking the archive, place the executable file in any directory that is not a Windows protected directory. For example, a good location for it might be something like C:\util. The ideal would be that this folder was also added to the system path.

As mentioned in [1], you can rename ctt.exe as ct.exe (or, if you like, make a second copy with this name) in order to have only the features of CompTree.

Click here to download the latest version of the CTT program.

Click here to contact the author by e-mail

Author's home page (Italian), author's curriculum (English).

Back to summary.

6. Credits and history of changes

The Tree Mode [1] emulates the excellent MS-DOS program CompTree 1.81 by Allan Hoiberg (Denmark) and may be considered as a port of it to Windows system with few enhancements. All options, errorlevel codes and beep tones of CompTree are supported with the same meaning (see the differences in [4]).

6.1. Changes in version 1.10

  1. The program offers the possibility of calculating a degree of coherence between the files being compared: the coherence C is a percentage value that is closer to 100 the greater the similarity (/P option). When carrying out the coherence calculation, it is also possible to store in special files the pieces of text in common or those that fall outside the intersection
  2. New options for Tree Mode:
    • /E: Set the list of text file extensions.
    • /M: Set the maximum amount of memory in MB allowed for loading files.
    • /P: Activate the coherence calculation and optionally record the details of the coincidences and discrepancies for the file pairs that give comparison error.
  3. New options for both Text Mode and Tree Mode:
    • /F: Indicate both source and target files with a directory name or wildcard specification and perform the comparison between two individual files that match them.
    • /G: Go to the results obtained when the program finishes the requested processing and perform some additional tasks.
    • /MAN: Open the ctt.htm manual if the file is in the program folder, otherwise open the on-line manual.
    • /VER: Check the latest version of the program and download it.
  4. New keystrokes in Text Mode:
    • F11 Open the ctt.htm manual if the file is in the program folder, otherwise open the on-line manual.
    • F12 Checks the latest version of the program and allows you to download it.
  5. Options can be specified by redirecting a file to stdin. The file must meet few requirements [3].
  6. If an option is repeated, the last instance applies, whatever the input channel, even when the repetition takes place in the same line.
  7. If the program is placed within the 32-bit program folder, the backup folder is placed in the user's local settings folder and no longer in the documents.

Back to summary.