Re program HUNT - J R Stockton, www.merlyn.demon.co.uk, >= 2008-10-12 This help text applies to the HUNT.(PAS,EXE) current at the above date, which may itself bear an earlier date. If the program is dated later, there may have been an optimisation or a minor fix. Bob Bissinnar's Windows Help file is via http://www.home.earthlink.net/~help_4hunt_exe/ General : HUNT is a variation on DOS 3.3's DIR, with many enhancements (some of which appear in the DIR of later DOS); it is used at your own risk; RSVP. HUNT was written, starting in 1988/89, primarily for my own use. Updates are put on the Web in my http://www.merlyn.demon.co.uk/programs/hunt.zip ; see also my http://www.merlyn.demon.co.uk/programs/00index.htm. There is a copy of HUNT at ftp://garbo.uwasa.fi/pc/turbopas/hunt.zip, but that is less often changed. HUNT.EXE is 16-bit, for DOS and for Windows DOS-boxes. HUNT lists the contents of directories & optionally subdirectories, and allows DOS internal and external commands to act on what it finds. It can select by name, size, date, attributes, and can process what it finds. HUNT does not recognise or give Long File Names, and probably never will; but see below. I believe that it will work on remote drives mapped to drive letters, but it, like me, has little knowledge of UNC paths. It is not recommended for systems with Short File Names disabled. In the supplied file name, HUNT converts / to \. Any effects of DOS's APPEND ASSIGN JOIN SUBST have not been considered. HUNT itself writes to Standard Output, and to Screen, but not otherwise. HUNT can be used on XP, but there is a risk of stack overflow (detected) when scanning many directories. Possibly some symlink problem? Operation : If present, Environment variable HUNTCMD is first scanned for Options, unless the second command-line parameter is #. In it, U has no effect. The first command-line parameter will define a set of files, as for the ordinary MS-DOS DIR command, including wildcards. With no parameters, '*.*' is used, else '.*' or '*.*' is added as needed. Subsequent parameters, here called Options, are processed in order; finally, the actual drive scanning is done using the first parameter. In an Option, initial '-' or '/' is ignored. Lone '-' or '/' is wrong. HUNT mostly uses Standard Output; thus one can pipe the output through FIND "/" &/or SLOW &/or a viewer, etc. The beginnings of output lines are chosen to suit '| SORT'. Options : Option selection is case-independent; $ means string; & means letter; n means digit, ## number. A = Alphabetical : filename is put first in the output line (for |SORT) B = Before date-time - as B89/11/27-19:55:46 or B#19:55:46 - truncatable C = ChDir : offer dir. of file or actual Dir. found; if yes, ChDir & exit D = Directories only are to be found; now implemented via Option K E = Ends-less; B F & W dates, and summary, will not be shown after E F = From date-time - as F2003/11/27-19:55:02 or F#19:55:02 - can truncate G& = Grant permission - & is any letter H$ = Holds - string $ must be in the 8.3 file name (H*$ - must not be) I$ = Ibid - insert $+directory where file found just before string S2 J$ = Jbid - insert $+directory where file found just after string S2 ? K = Kind - 8-char string of attributes 0 = off, 1 = on, else don't care L = Leave subdirs scan to Later than files, rather than before files M$ = Media - $ is string of drive letters (N.B. C cannot change drive) N = New (current date) files only, = W# O = Only put filenames on Standard Output; put E or O before any F,B,W,Y P = Path from CurrDir is put at end of line (if no ") - useful with S|sort P+ uses full Path. With O, P- uses no Path, and Pn is added, see below. Q = Quote/Quiet - Q = Q7 : Qn bits 0 for *, 1 for result, 2 for question R = Rootwards directories also, no PATH search S = Subdirectory contents also, no PATH search T = "TYPE" U = Unconditionally - use with '".."' to prevent question V& = Veto permission - inverse of G W = When - file date/time matches exactly; uses B & F; W# W#-n whole day X = eXecutable .COM, .EXE, .BAT files; with P, searches PATH using GetEnv Y = Yesterday and after (F#-1); W#-1 is yesterday only Zñ## = only shows if siZe >= +## or <= -## or = =## bytes ; needs + - = ".. .." = command string 1 or 2 (see below) ~*~ = variable character * replaces " above henceforth in line + = put no space after S1 or before S2 ; = comment : all further parameters are ignored 2 = 2 digit years (from 1998/01/02, changed 2000-08-09) # = disables HUNTCMD, when second parameter * and \ are ignored (so can default for the first parameter in a *.BAT) œ = wait for keypress before end (Shift-3 or Alt-156). $ may work too. O Pn combination - now bit-mapped. Consequence : O P means O P0 and so now differs from O without P. Bit 0 = 1 = include file name Bit 1 = 1 = expand path to absolute (otherwise relative), unless - Bit 2 = 1 = suppress path part. Q Option - this is bit-mapped. The default is Q7. Q alone clears the LSB. Bit 0 = 1 = enable output of "directory route" lines - matches earlier Q Bit 1 = 2 = enable output of "file information" lines Bit 2 = 4 = enable output of "question" lines when not essential. HUNT *.ext q0 e "program" "more parameters" u > somefile therefore directs all the standard output of program into one file. With B F & W, if the next char is "#", it represents TODAY, next is time; if "-" follows "#", the "days-before" number follows, followed by time; the default epoch fields represent 2000/00/00-00:00:00. "##" is 'now'. New: F##-n is OK; <1980 check! Seconds are first truncated to be even. NOWMINUS (same location) can set the date/time to the environment. For the end of the day, use hour 24. Any non-digit ends a field. HUNT /? gives very minor HELP, reminding of the above Options. Commands : The Options may include one or two strings, S1 S2, each bounded by '"'; if so, for each file found the string 'S1 S2' is offered for %COMSPEC% (Unconditionally if any Option starts 'U') [if "S1"="", DOS will (ignoring <.ext>) want to execute '.COM/EXE/BAT S2'] (if 'S1...S2' changes the list of files, caution!); 'T' means '"TYPE"'. At the offer, give the first character of: Yes (to do), No (to not do), Unconditionally (to do all the rest), Quit (to offer no more) or Skip (to skip the rest of the files in this directory); or ESCape. Commands are done during listing. By default they are not performed for Hidden or System files; use Options Gh & Gs to allow these. Options G & V : G enables, V disables. A - Filesize, totals round up to cluster Allocation; see RBIL *.F D-211C; auto-cluster-size may be unreliable. Try DIR /V on a small file. Use Ga## to specify cluster size, just Ga to guess. B - Select only files whose SFN (8.3) has an unauthorised character. D - Column of ISO Day-of-Week Number; if followed by a digit string, selects only those days. Use Gd? to select bad datestamps. H - Commands on Hidden files I - Date/Time separators as ISO 8601. Use GiXYZ to choose each; 0 for space. S - Commands on System files U - UNC veto disabled Examples : HUNT FRED x p should show all files >FRED might now execute, in order; HUNT \ x s should show all executable files. HUNT *.txt b#-7 "copy" "d:\save" u copies all *.txt over 7 days old to directory d:\save . Try HUNT * s p q "fc" id: "*.*" - Option I allows citing related files. Much can be done by invoking a suitable ad hoc batch file, e.g. HUNT * s "diff c: d:" ; where DIFF.BAT contains FC %1%3 %2%3. Consider HUNT * "hunt a:" + " s ~#~ #copy# #b:#" & HUNT HUNT.* ~'~ 'FIND /I "find"' u ! In a batch file, HUNT * | find "Date" | COLS 56+19 | STOW Last HUNT * e w%Last% will show all files timestamped the same as the most recent one found; use 34+19 for the oldest. My COLS & STOW are in the same Web directory as released HUNT - i.e. programs/. HUNT con f2002-11-15 "PROG parameters" u will execute "PROG parameters" on & after that date, since CON is stamped 'now'. There will be an extra tail parameter, CON. HUNT *.pas h123 will find the .PAS files for which filename holds '123' anywhere. HUNT *.awk mCF s p q will find all .AWK files in the current directory subtrees of C: & F:; in the M string, '.' means the current drive, other non-letters are ignored. HUNT $*.htm "NOWMINUS o" + " y1 r o*" u e will subtract a year from the datestamps of the files; my program NOWMINUS. For DOS dir-type selection on LFNs combined with other HUNT facilities, consider the following, on one line :- dir "abcdefghijkl 20*.txt" | find "/" | COLS 'HUNT * ` 1-8 '. 10-12 * 'b#-7 * q 'del q * 'e * 'u > $$$.bat gives in $$$.BAT lines like HUNT ABCDEF~3.TXT b#-7 "del" e u thereby deleting files passing a dir name criterion and a HUNT date one. General Notes : A ? follows listed names with 'bad' characters or date (a very partial malware, etc., test) : try >HUNT \ s p q | find "?" HUNTTEST.ZIP contains strangely-dated zero-length test files. Attributes, in order 0..7, are Read-only, Hidden, System, VolumeID, Directory, Archive, and apparently somewhere Alias and Compressed. Attributes 6 & 7 are not usually used (devices have 6 set); so piping through 'FIND ".."' will pass only "file" lines, and not header or footer lines. But see the E Option now for that. HUNT is compiled with TurboPascal BP7.01, in real (MSDOS) mode; but TP5 should be enough. Borland Museum has free TP5.5, France has free TP7.01. For differently-arranged details, and for more details including LFN in Win32, use my FILGEN16/FILGEN32. Example : HUNT *.exe e q0 u f#-9 "FILGEN32 /(N9d,9'y9:)#D#P" > somefile gives as Dec 1, '02 : "C:\pas-prog\OMIT.EXE" FILGEN32 should be able to report disc space over 2GB. With options R & S, there is some limit (about 23?) on the number of directory steps away from that implied by the first parameter; Error 202. Numeric Limits : Disk & Free bytes reported are capped at 2147155968 = 2^16*(2^15-5); or similar OS-dependent number. (RBIL .h D-217303) Byte and file counts will roll over at 2147483647, to -2147483648. (RBIL?) Errors : Bad Options are trapped and give curt messages. Pascal runtime errors known possible, with possible causes, include 202 : Stack Overflow : Directory structure too deep from here OR as a side-effect of length (chars) of SFN path too big, recently (20081012) deduced and under consideration 201 : Range check error : e.g. by Option F66666 For (unexpected) others, see in a DOS book. ErrorLevels : 0 : success, with something found 1 : success, with nothing found 2 : Escape given as response 3 : general command line error, or /? 4 : DOS error in FindFirst 9 : default for output error, such as disc full Changes to Function : 1994/09/14 : Keyboard response was Readln(Para), is Para := ReadKey 1994/09/29 : if later in line, N supersedes F|B and vice versa 1995/02/02 : after F|B, today is # (was =) Note : within actual "..", > >> < | are preserved for the S1 command. 1996/07/08 : OK with (does not show) W95 long file name entries. 1997/12/15 : made Year 2044 compliant. 1998/01/04 : Options 2 & 4 - force #YearDigits. 1998/02/03 : Crt removed, ReadChar replaces ReadKey. 1998/07/20 : Option D- - no directories shown. 1999/01/24 : Option C changed ? if D, change to dir found. 1999/03/20 : "?" repositioned for Option A; 8; may be ~ 20. 2001/04/09 : Extra space before b & f, for SORT. 2001/07/10 : Dots in HUNT * s o more consistent. ? into (y/n/U/Q/S/?). 2001/10/17 : HUNT * x p o fixed 2001/12/08 : ID line only in Help. Option E, Ends-less, omit top & tail. 2001/12/09 : Option Zñ##, only files size >= +##, <= -##. 2002/01/15 : Option Kind - for selection by Attributes on/off. 2002/01/31 : This material removed from HUNT.PAS; now only here. 2002/02/20 : Option Holds - 8.3 name holds string. Also Option œ (GBP). 2002/02/24 : Option Z now includes =, size exact match. Option W. 2002/02/26 : Earliest and latest datestamps now in footer; see COLS. 2002/07/21 : Media Option implemented. 2002/08/04 : SubOption P+ : full Path given. BULLER removed (NBG>Jan). 2002/09/09 : ErrorLevel changes. 2002/09/22 : Action of B F W refined. 2002/09/24 : F##-n B##-n, X days before present moment. 2002/10/03 : $ for œ (wait), until needed for a new Option! G & V reserved. 2002/10/27 : H*$ for string $ must *not* be in 8.3 filename. 2002/11/01 : Environment HUNTCMD is first scanned for Options. 2002/11/02 : In Option M, shows Directory not Drive; & Full Names adjusted. 2002/11/18 : File date validity check now checks Day<=EndMonth. 2002/11/18 : Counts increased to longint (2^31-1) from word (2^16-1). 2002/11/18 : if second parameter is # then HUNTCMD is not scanned. 2002/11/23 : P- omits path part used with O. ?? 2002/11/24 : X+ is equivalent to X P. 2002/12/03 : U now ignored in HUNTCMD. 2002/12/05 : Q given bit-mapped suffix. 2002/12/06 : W# W#-n now match a whole day (as will W##). 2003/03/21 : Semicolon comment parameter added. 2003/06/18 : F, &c, now show MM DD hh mm ss as truncated into a filestamp. 2003/06/18 : G & V, initially just for operating on H & S files. 2003/07/28 : Ga - file size is bytes Allocated, assuming Int21/1C works. 2003/08/12 : File-date-range now independent of Q Option. 2003/09/?? : Ga, as auto-cluster-size is unreliable. 2003/10/18 : UNC path bar - param 1 must not start \\. Option GU may allow. 2003/11/03 : In file name, / converts to \. 2003/12/18 : ISO Day-of-Week Number enabled by GD[#]. -/19 : and GD? & GB. 2004/03/03 : "entries" added to report, helps find empty directories. 2004/12/21 : New location, above, for Bob Bissinnar's HUNT.HLP. 2005/02/14 : Gi for ISO 8601 separators; Gi... for arbitrary ones. 2005/04/15 : Option P allows O Pn format control; effect of O P changed. 2005/09/20 : Date/time now midnight-safe. 2007/12/13 : Add warning & omission of path elements with spaces. http://www.merlyn.demon.co.uk/programs/hunt.zip ------------