- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- How do you determine if a directory is empty or no...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 01:16 AM
тАО09-09-2005 01:16 AM
Is there a way to determine if files exist in a dirctory and return a "TRUE" or "FALSE" string?
If not, how can this be accomplished?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 01:20 AM
тАО09-09-2005 01:20 AM
Re: How do you determine if a directory is empty or not?
Use the lexical function F$SEARCH("[directory]*.*") to locate any file in the directory. If it comes back with an empty string ("") then there were no files in the directory.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 01:24 AM
тАО09-09-2005 01:24 AM
Re: How do you determine if a directory is empty or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 02:05 AM
тАО09-09-2005 02:05 AM
Solution$ IF F$SEARCH("[sssss]*.*) .EQS. ""
$ THEN
$ ...
$ ENDIF
There are also equivalent ways to express the IF using the F$LENGTH lexical function wrapping the F$SEARCH.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 02:16 AM
тАО09-09-2005 02:16 AM
Re: How do you determine if a directory is empty or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 02:20 AM
тАО09-09-2005 02:20 AM
Re: How do you determine if a directory is empty or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 02:25 AM
тАО09-09-2005 02:25 AM
Re: How do you determine if a directory is empty or not?
E.g.
x=f$sea("qqqqqq.qqqqqq")
x=f$sea("dir:*.*")
if x .eqs. "" ...
If not, f$sea will return each file of the directory (1 in each loop), then a blank ("") and then restart returning the files.
Wim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2005 05:04 AM
тАО09-09-2005 05:04 AM
Re: How do you determine if a directory is empty or not?
if you like boolean value this is your example:
$ flag_empty=f$search("dir:*.*").eqs.""
$ if flag_empty
$ then
$ ... Directory empty
$ endif
$ ...
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2005 04:04 PM
тАО09-12-2005 04:04 PM
Re: How do you determine if a directory is empty or not?
$ check_dir="disk:[mydir]"
$ search_context=='search_context'+1
$ ctx=search_context
$ tmp=F$SEARCH("clear",ctx) ! Clear to start
$ dir_empty=F$SEARCH("''check_dir'*.*",ctx).EQS.""
$ IF dir_empty
$ THEN
$ ! directory is empty
$ ELSE
$ tmp=F$SEARCH("clear",ctx) ! Clear at end
$ ENDIF
The global symbol "search_context" is used to generate a stream-id for the search. This code can safely execute within another F$SEARCH loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2005 03:06 PM
тАО09-13-2005 03:06 PM
Re: How do you determine if a directory is empty or not?
Ken wrote
"Is there a way to determine if files exist in a dirctory..."
yes, many
"... and return a "TRUE" or "FALSE" string?"
Yes, but returning a those strings is a little bit strange request. Most applications would look for a symbol set to true or false or (or perhaps 1 and 0 )
Anyway, just to give a completely different solution:
$directory = "XXX.DIR.1"
$string = "TRUE"
$open/read/share=write dir 'directory
$read/end=empty
$string = "FALSE"
$empty:
$close dir
$write sys$output "It is ", string, "that directory ", directory, " is empty.
grins,
Hein.
$write