Operating System - OpenVMS
1753525 Members
5578 Online
108795 Solutions
New Discussion юеВ

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

 
SOLVED
Go to solution
John McL
Trusted Contributor

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

John G's question is very valid - why are these files being created? It may be a lot easier to prevent them being created than deleting them afterwards, and it will save the resources used when creating the file.

If you have no choice but to clean them up afterwards then maybe they have a naming convention that will help identify them. Use something like

$ WILD_FILE_NAME= "ABC*.*"
$ LOOP:
$ THIS_FILE = F$SEARCH(WILD_FILE_NAME)

This might avoid deleting the wrong file.
Shriniketan Bhagwat
Trusted Contributor

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

Hi,

Who creates these files? Is it your application, when executed? If there is any specific pattern in the file name, then you can use the pattern to search the files using F$SERCH lexical as provided by the John Gillings. Be careful while deleting the files (you may not want to delete impotent files accidentally). As John Mcl said, it is good to prevent creation of such unwanted files than deleting then later. Prevention will save your precious time every time.

Regards,
Ketan

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

Hi All,

Thanks for your comments.
Zeni B. Schleter
Regular Advisor

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

My two cents... If this is a one shot effort, taking the output of the directory listing mentioned and editing it to do the delete is fairly quick. If this is repetitive then you can also use the f$file_attribute lexical function to check on creation dates or modified dates as well as the size of the file.

I would still use the Open/Close check if unsure whether the file is in use or not.
Paul Jerrom
Valued Contributor
Solution

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

What's the real problem? Loads of files in a directory? If they all have the same name and there are multiple versions being created and you are SURE you don't want to see the contents then you can set a file version limit - "$ SET FILE/VERSION_LIMIT=10 tmp.txt" will limit the number of occurances of tmp.txt to 10 (automatically deleting previous versions when needed). Although you'll have to purge the files down to the required number first ("$ PURGE/KEEP=10 tmp.txt").
But you'll need eventually to tackle the problem at source - find out what is creating the files and stop it!
Have fun,

Peejay
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If it can't be done with a VT220, who needs it?

Re: To delete a file if the sie of the file is less than 1 blocks in OpenVms

Hi all,

i have found out the issue why it was creating multiple files with 0 blocks. thanks a lot for your help. i have made the changes in the com.

Thanks to all once again.