HP OpenVMS Systems

ask the wizard
Content starts here

Purging a directory?

» close window

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
$ then
$    write sys$output "more than ''limit' files"
$    exit
$ endif
$ x = x + 1
$ goto loop
  The exact solution is left up to the reader.

answer written or last revised on ( 20-MAR-2000 )

» close window