How to delete mutiple RMS files using ##class(%Library.File).ComplexDelete(FILE) with openVMS?
All,
I'm using Cache 2014.1 in an openVMS environment.
If I have multiple RMS files to clean up, for example.
!DIR MEMBER_EXTRACT.*;*
MEMBER_EXTRACT.CSV;2 MEMBER_EXTRACT.CSV;1
MEMBER_EXTRACT.PROC;1 MEMBER_EXTRACT.TXT;3
MEMBER_EXTRACT.TXT;2 MEMBER_EXTRACT.TXT;1
S FILE="MEMBER_EXTRACT.*;*"
Do ##class(%Library.File).ComplexDelete(FILE)
!DIR MEMBER_EXTRACT.*;*
MEMBER_EXTRACT.CSV;1 MEMBER_EXTRACT.TXT;2
MEMBER_EXTRACT.TXT;1
Total of 3 files.
What would be the best way to delete all the files using the ComplexDelete class call?
ComplexDelete does't appear to handle the versioning of the RMS files, is this correct?
I know I can whack the files using S ST=$ZF(-1,"DELETE MEMBER_EXTRACT.*;*") but I was hoping
to accomplish this task without calling out of cache.
Thanks for your help.
Comments
The ComplexDelete classmethod uses the FileSet query:
ClassMethod ComplexDelete(filename As %String, Output return As %Integer) As %Integer
{
Set resultset=##class(%ResultSet).%New("%File:FileSet"),return=0
Do resultset.Execute(..GetDirectory(filename),..GetFilename(filename))
Set exit=1
For {
Quit:'resultset.Next()
Set file=resultset.Data("Name")
Set r=$$$FileDeleteRet(file) If r,exit Set exit=0,return=r
}
Quit exit
}The problem is, that query treats ";" as a delimiter separating multiple search patterns.
You could replicate the method but specify another delimiter (e.g. comma) when you Execute the query to get the resultset (untested code):
Do resultset.Execute(..GetDirectory(filename),..GetFilename(filename),,,",")Maybe someday ISC will enhance ComplexDelete to take an optional delimiter argument.
Incidentally, did the VMS directory you ran your ComplexDelete("MEMBER_EXTRACT.*;*") on contain any files other than MEMBER_EXTRACT.* ones? Because if it did, my hunch is they all had their latest version deleted by that call because of how the semicolon gets treated as a delimiter of wildcard patterns.
Hi John,
Thanks for looking at this for me.
The directory contains thousands of other files. I didn't do a file count on the entire directory before I ran the ComplexDelete("MEMBER_EXTRACT.*;*") call. I'll test your hunch and see if I deleted any files that I
didn't intend to.
it looks like only "MEMBER_EXTRACT*" files were touched
!DIR MEMBER_EXTRACT*
MEMBER_EXTRACT.CSV;2 MEMBER_EXTRACT.CSV;1
MEMBER_EXTRACT.DAT;1 MEMBER_EXTRACT.PROC;3
MEMBER_EXTRACT.PROC;1 MEMBER_EXTRACT.TXT;3
MEMBER_EXTRACT.TXT;2 MEMBER_EXTRACT.TXT;1
Total of 8 files.
!DIR *
......
Total of 2932 files.
S FILE="MEMBER_EXTRACT.*;*"
S ST=##class(%Library.File).ComplexDelete(FILE)
W ST
1
!DIR MEMBER_EXTRACT*
MEMBER_EXTRACT.CSV;1 MEMBER_EXTRACT.PROC;1
MEMBER_EXTRACT.TXT;2 MEMBER_EXTRACT.TXT;1
Total of 4 files.
!DIR *
......
Total of 2928 files.
W 2932-2928
4