summarize files in a directory
Bill Ezell
wje at sii.UUCP
Mon Feb 6 06:13:09 AEST 1984
b
Here is a simple program for keeping track of files in a directory.
It keeps a list of files and a one line description for each, and compares
this list to the actual directory contents when it's run. If a new file
has been added, it asks for a one line description. If a file has been
deleted, it removes the entry from the list of files. It is written
in AVL, but can probably be implemented in C without too much work.
Anyone else have other quick but useful programs like this?
-Bill Ezell, Software Innovations, Inc.
(decvax!sii!wje)
(ittvax!sii!wje)
______________________
main() /* keep a summary of files in a directory */
{
pipe("ls","r",fd); /* see what files we have */
while( sread(fd,line) )
if( line $!= "^summary" ) new[line] = True;
close(fd);
foreach(node,new) /* compare new list to old */
{
name = this(node); /* the subscript name */
if( !exist(^summary[name]) ) /* a new file */
{
printf("Description of file '%s'? ",name); input(line);
node = line;
}
else
node = ^summary[name]; /* already defined */
}
^summary := new; /* update record */
printf("Summary of files:\n\n"); /* we could have done this above */
foreach(node,new)
printf("%s - %s\n",this(node),node);
exit(0);
}
More information about the Comp.sources.unix
mailing list