Sift plugin for Take Command / TCC
beta version 0.71.2 2021-09-23
This plugin provides a quick way to find the n largest, smallest,
oldest, or newest files in one or more directories or directory trees, and sort
them into an array variable. It adds one new command,
SIFT; one new internal
_SIFT; and one
Note that because this plugin returns results in an array variable, it is incompatible with the free TCC/LE. TCC/LE does not support array variables; trying to load this plugin will fail with an error message.
To use this plugin, copy Sift.dll to
some known location on your hard drive. (If you are still using the 32-bit
version of Take Command, take Sift-x86.dll
instead of Sift.dll.) Load the plugin
PLUGIN /L command, for example:
plugin /l c:\bin\tcmd\sift\sift.dll
If you copy this file to a subdirectory named PlugIns within your Take Command program directory, the plugin will be loaded automatically when TCC starts.
The syntax definitions in the following text use these conventions for clarity:
|indicates text which must be typed exactly as shown.|
|indicates optional text, which may be typed as shown or omitted.|
|Bold italic||names a required argument; a value must be supplied.|
|Regular italic||names an optional argument.|
|ellipsis…||after an argument means that more than one may be given.|
SIFT — Returns a sorted list of files in an array.
/I /R /T:stamp
/U /V /Z n
|select files by attributes (the default is all files):|
|Character separating the time from the date|
|return date stamps in ISO 8601 format, YYYY-MM-DD|
|recurse into subdirectories|
|selects which date stamp to use:|
|return date stamps as UTC (not localized)|
|dump the array to stdout when done|
|localize date stamps dumbly, like DIR and Explorer|
|n||the number of files to return, 1 — 4096; defaults to 10|
|criterion||the quality used to find and sort files:|
|array||name of the array to create and fill|
|filespec…||wildcard filespecs to match|
|return fully qualified filenames|
|do not insert commas in file sizes|
|do not recurse into hidden directories; only useful with |
|do not include Descript.ion files|
|do not recurse into junctions; only useful with |
filespecs may use directory aliases, wildcards including character sets in square brackets, and include lists. If you do not specify any filespec, then * (all files in the current directory) will be supplied by default.
An n-by-3 array will be created to hold the
resulting list. (If an array by the same name already exists, that array will
be lost.) Column 0 of the array holds filenames, column 1 holds the
files’ sizes, and column 2 holds their date stamps. The filenames
returned in column 0 will be fully qualified if either
/R was specified, or if more than one filespec
was supplied; otherwise filenames are stored without paths. The date stamp
/T: is returned in column 2, and is also used for
NEWEST is specified.
LARGEST is specified or there is no criterion,
files will be stored in the array in decreasing order of size, i.e.
row 0 will hold the largest file, row 1 will hold the next-largest, and so on.
SMALLEST is specified, then files will be stored in increasing
order by size. If
OLDEST is used, then files will be sorted into
chronological order; and
NEWEST, in reverse chronological order.
If multiple files have the same size or the same date stamp, then the first one
discovered “wins” — which one is found first depends on
sift 20 largest bigdlls c:\windows\system32\*.dll
… finds the 20 largest .DLL files in C:\Windows\System32, and sorts them into a 20-by-3 array named BIGDLLS.
Only the array name is mandatory:
… is legal, and will sort the 10 largest files in the current directory into a 10-by-3 array named BIG.
_SIFT — Returns the number of
files found by the last successful
If SIFT has not yet been called,
_SIFT returns -1. If
SIFT fails for some reason (bad syntax?) then the value returned
_SIFT is unchanged.
@SIFT — Returns the full
name of the single largest (smallest, etc.) matching file.
|attribs||supported attributes are |
|flags||bitmapped: 1 recurse, 2 no junctions, 4 no hidden directories, 128 exclude Descript.ion files|
@SIFT function provides an easy way to find the single
largest, smallest, oldest, or newest matching file in a directory or directory
tree, without the overhead of an array. It returns a fully-qualified filename.
(It only returns a filename; if you want to get the size or time
stamps of the file, call TCC’s internal
@FILETIME functions as usual. This
function is potentially very slow, so calling it multiple times to retrieve
different information about the same file would be a bad plan.)
You must supply a filespec; it may include a directory alias.
If no matching files are found, this function returns an empty string.
• Note: While this particular function does not use an array, you still cannot load this plugin in TCC/LE or in older shells which don’t support arrays.
This plugin displays an informational line when it initializes. The
message will be suppressed in transient or pipe shells. You can disable it
for all shells by defining an environment variable named
set /e /u noloadmsg=1
Status and Licensing:
Consider this beta software. It may well have issues. Try it at your own risk. If you find bugs, you can report them in the JP Software support forum.
Sift is currently licensed only for testing purposes. I may make binaries and source code available under some free license once I consider it ready for use.
You can download the current version of the plugin from http://prospero.unm.edu/dl/sift.zip or ftp://prospero.unm.edu/sift.zip.