Delete A File From The Ifs

Delete A File From The Ifs 7,2/10 9137reviews
Delete A File From The Ifs

Transaction files keep coming into the system, and after having been processed (read) they are moved to an IFS directory 'archive'. We now have more than 90.000 files from last 26 months. I have considered various solutions like 'ls' to a file, and then read via pgm and execute delete, BUT something tells me that there is a better solution. RE: Delete IFS files WITHOUT deleting the directory -- No. RMVLNK is similar to DLTOBJ. The * in the path is a wild card that means any. So the effect is to remove.

This article was inspired by a recent support call I received. It made me realise that many of you may not have noticed that IBM added a handy parameter to the RMVDIR (remove directory) command back in v6.1 called SUBTREE. Let me set the scene and you can work out whether this is something that may be useful to you. If it is useful but something you think you already know about, be sure to skip down to my Pro Tip below on handling read-only objects before you abandon me. RMVDIR fails with CPFA0AC – Directory contains objects Imagine you have a need to delete a directory from the IFS but it is not empty and when you issue the RMVDIR command, you get error CPFA0AC – directory contains objects.

Basically, this command (in its default form) only works if the directory is empty. This is about as much use as the proverbial chocolate teapot. Can you imagine if IBM had done the same with libraries? You would not be able to issue a DLTLIB command unless you deleted the contents of it first.

In the example below, we have a directory called “Backup” in which we put copies of applications before upgrading them. Once the upgrade is complete, we want to remove them. In this case, there can often be thousands of objects in hundreds of subfolders. The prospect of going through them all individually to delete them is about as appealing as a getting a haircut by Sweeney Todd. Download Ssf2 Save Data In Gba.

If you wanted to automate this in a CL program, then it would become even trickier. But if we use the “Directory Subtree *ALL” parameter, then all this hassle goes away. In one simple command we can remove a directory including any objects and subfolders contained within it. Pro Tip: Watch out for CPFA1C5 Object is Read Only. Even if you’ve got *ALLOBJ, the RMVIR command still fails if any of the objects within it have the “read only” attribute set to yes. A sample of this error is shown in the screen shot below: You can get round this using the CHGATR command.

This allows you to remove the Read Only attributes for any and all objects contained in a folder or subfolder using (you guessed it) the Subtree *ALL parameter. There is a sample of this in the screen shot below. You can even script this method in a simple CL Program: RMVDIR DIR('/backup') SUBTREE(*ALL) MONMSG CPF0000 CHGATR OBJ('/backup') ATR(*READONLY) VALUE(*NO) SUBTREE(*ALL) MONMSG CPF0000 RMVDIR DIR('/backup') SUBTREE(*ALL) Now, for those of you who think I’ve gone potty or perhaps just made a mistake by leaving that first RMVDIR command there, bear with me.

I know the RMVDIR is going to (or at least likely to) fail but this extra command can still save you time. You see, the way the RMVDIR command works is that even if it can’t complete normally, it will remove all that it can, simply skipping the problem files and continuing until it has attempted to delete every candidate object.