Dec 092017
Delete all files in a dir BUT those matching mask(s).
File ALLBUT.ZIP from The Programmer’s Corner in
Category File Managers
Delete all files in a dir BUT those matching mask(s).
File Name File Size Zip Size Zip Type
ALLBUT.DOC 3859 1533 deflated
ALLBUT.EXE 21520 11718 deflated

Download File ALLBUT.ZIP Here

Contents of the ALLBUT.DOC file


Copyright 1989 William C. Scott

ALLBUT is a utility to delete all files EXCEPT those matching
a 'mask' or list of masks, determined by the user.



Typing 'ALLBUT' on the command line will bring up a
short information screen.

Note the wildcards follow the patterning of DOS wildcards. For
example, DEL *nt*.* will delete everything in a DOS directory,
so, conversely everything will be retained if ALLBUT *nt*.* is
used. BEWARE: ALLBUT .* will delete *EVERYTHING*, just as
DIR .* displays everything.

Parameters that will be accepted on the command line include:

A drive/path specifier, (must be first parameter) e.g.,

'ab a:' or 'ab c:\mydir'

ALLBUT will change directory to the specified path before
working its misery on the files therein. (The two examples
above would do nothing more than change the directory.) It will
then change back to the original directory.

Up to nine masks will be accepted on the command line, for

'ab *.pas *.exe *.com' will delete ALL files in the current
directory EXCEPT those with a .PAS, .EXE or .COM

'ab a: *.exe autoexec.bat' will delete ALL files on drive A's
current directory, EXCEPT those with a .EXE
extension or a name of 'AUTOEXEC.BAT'.

'ab c:\mydir *.com' will delete ALL files in the
subdirectory MYDIR on drive C,
EXCEPT those with a .COM extension.

FIVE switches are currently allowed. Those are /C, /D, /H, /I, /V

'/C' allows you to change the internal masks and clone a
new copy of ALLBUT with the new masks.

'/D' displays the list of internal filemasks.

'/H' or no command line parameters causes a help screen
to be displayed.

'/V' issues a verification prompt for each file matching the
deletion mask(s).

'/I' turns on the internal filemasks for a single
invocation of ALLBUT.

So, a command line entry of "AB /I" will delete ALL files in
the target directory EXCEPT those matching one or more of the
internal masks.


ALLBUT *might* strike some as unnecessary but I have had many
occasions where I needed it. Perhaps you have had the same
experience. It basically operates as an inverse of the DOS
'delete' command line parameters.

The command line can be used to augment the internal masks if so
desired. Just type /I and your other masks on the command line.
Either may be first.

Although the source uses Turbo Power's TPCRT unit, the changes to
remove dependence on that are fairly simple and not too penalizing.
I can and will include the TPClone unit that Turbo Power provided
as part of the 'BONUS' package and graciously has consented to
allow users to distribute. The FASTWRITE functions are all I'm
using from Turbo Power in ALLBUT, aside from the FASTWRITE.

I can be found on GENIE as 'WILLSCOTT'.
Compuserve user# 71406,1251.
Phone: (405) 927-3840.

Being a shut-in (housebound), phone calls ARE welcome .

 December 9, 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>