Dec 092017
File attribute changer w/ C source.
File CA.ZIP from The Programmer’s Corner in
Category File Managers
File attribute changer w/ C source.
File Name File Size Zip Size Zip Type
CA.C 15274 4837 deflated
CA.COM 3888 2607 deflated
CA.DOC 4497 1764 deflated

Download File CA.ZIP Here

Contents of the CA.DOC file

CA.COM by Mark Adler Pasadena, CA 1988.

CA is a command used to change and examine file attributes. Entering


may give a display like:


which is a list of files in the root directory and their attributes.
The first column of attributes is either '-' or 'r' for read/write or
read/only. The second column is either '-' or 'h' for visible or
hidden. The third column is '-' or 'y' for typical or system, and the
fourth column is '-' or 'm' for backed-up or modified.

To change attributes, there are eight options to set each of the four
attribute bits to their possible values. For example, the command:


would try to change all the files in the current directory to the
backed-up status and would display, for the example directory above:

changed CONFIG.SYS
2 files' attributes changed

Note that CA only changed the files that needed to be changed. See
below for a complete listing of the options.

CA can take file names to narrow down what is changed. For example:

ca/vt *.com

will make all the .COM files visible and typical, so for the above
directory, the system files IBMBIO.COM and IBMDOS.COM would show up in
the normal directory listing.

CA can also perform these operations to all the files contained in a
subdirectory and its subsubdirectories, etc. The option for this is

ca/sr \dos

will make all the files in \DOS read-only.

Alternatively, CA can change all the files that match a particular name,
but in all the subdirectories. The option for this is "/F" (find):

ca/fr \*.exe

will make all the .EXE files on the current drive read/only, no matter
where they are.

CA can prompt you before changing the attribute of each file. For

ca/pb *.*

will, for each file in the current directory that has been modified
since the last backup, ask youif it should change the modified bit or

Change file FOO.C (y/n)? _

You must then answer y, n, Y, or N. Any other response is ignored.

CA takes options that are preceded by a slash (/). The command line is
read from left to right, processing options and file/path names as they
appear. However, options that are appended to a file/path name take
effect before that name is processed. For example, this command would
do the same thing as "ca/r *.exe":

ca *.exe/r

But the command "ca *.exe /r" (notice the extra space before the /r),
does NOT do the same thing. In this case, the files are listed with no
changes made and the /r is an option left hungry for an argument to work

Since there are options to change the defaults along a command line,
there are options to change them back for processing the next thing
on the command line. All the options are listed here:

/R - Change attribute to read-only.
/W - Change attribute to read-write.
/H - Change attribute to hidden.
/V - Change attribute to visible.
/Y - Change attribute to system.
/T - Change attribute to typical.
/M - Change attribute to modified.
/B - Change attribute to backed-up.
/L - No change---just list files and their attributes (default).
/S - Include matching subdirectories and all of their contents.
/N - Ignore subdirectories (default).
/F - Include all files that match pattern in all subdirs.
/A - Include all files in subdirectories, period (default).
/P - Prompt for each deletion or removal.
/Q - Quiet---don't prompt (default).
/? - Display version number and list of options.

A complicated example of CA is:

ca /frp \*.com \*.exe /l \*.com \*.exe

which prompts to change all the .COM and .EXE files on the current drive
to read-only and then lists all the .COM and .EXE files on the current
drive along with their (possibly new) attributes. The /L turns off the
change turned on by the /R. The /P is ignored when listing, so it was
not necessary to turn that off with /Q.

Version history -

1.0 5 Jun 1988 First public version
1.1 18 Nov 1988 Fixed for Turbo C 2.0 (label needs statement)

Feel free to send any problems with or comments on CA.COM to:

Mark Adler
P.O. Box 60998
Pasadena, CA 91106

 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>