The Question is:
I have an application which produces more than 5000 files into a directory
daily. I need to keep the number of files down to below 800. I can write
a program to do this but would like to know if there is a VMS feature I can
use to automatically keep the file count at 800 - thus avoiding any defevlopment effort.
The Answer is :
There is no mechanism to limit the number of files (save for the
file version limit mechanism; see SET DIRECTORY/VERSION_LIMIT) and the
PURGE mechanism, but creating a DCL script would take approximately as
long as it has taken to compose a text answer for this question.
Here is DCL code that performs roughly the requested task, though no
deletion and no particular selection criteria (likely needed for most
directory-processing applications) has been applied:
$ x = 0
$ limit = f$integer("''p1'")
$ y = f$search("sys$login:*.*;*",1)
$ if y .eqs. "" then exit
$ if x .gt. 10
$ write sys$output "more than ''limit' files"
$ x = x + 1
$ goto loop
The exact solution is left up to the reader.