- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- DCL get number of files in a directory
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
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
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
тАО10-30-2008 09:39 AM
тАО10-30-2008 09:39 AM
Is there a system function (Lexical/Lib/Services) to get the number of files in a directory like "$ DIR/GRAND directoryname" DCL command?
I'm trying to avoid having to write output of DIR/GRAND to a file and then extract the info.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 10:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2008 05:03 AM
тАО10-31-2008 05:03 AM
Re: DCL get number of files in a directory
Here's why...
The directory doesn't contain one record per file. It contains one record per file name and the record includes several sub-entries, one for each version. So you cannot count directory records. It is possible to have 1000 files in a directory but only one (very long) directory record holding one name, one type, and 1000 versions.
So there is nothing you can look at in the directory from a DCL program to tell you how many files are in it. Only a directory-aware program (like DIRECTORY.EXE) can do this for you. You could just "roll your own" program to read the directory and return the count, but why re-invent the wheel? Trap the output of the DIR command and get the answer. Don't avoid the easiest method just to avoid the overhead of creating, reading, and deleting a throw-away file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2008 06:39 AM
тАО10-31-2008 06:39 AM
Re: DCL get number of files in a directory
For OpenVMS the SEARCH/STAT command will define DCL SYMBOL: SEARCH$RECORDS_SEARCHED
If you just want to count, then be sure to use a 'clear' DIR command, not an alias to avoid the fiel header IOs'. I tend to use a spelled out DIREctory or DIREx
Picking up the count form DRIECTORY/GRAND using a pipe is probably the most efficient.
But you _could_ figure it out with DCL:
$tot = 0
$num = 1
$open/read/share=write/error=done dir 'p1
$
$loop:
$read/end=done dir rec
$nam = f$cvui(3*8,8,rec)
$cnt = ( f$len(rec) - nam - 4 ) / 8
$tot = tot + cnt
$num = num + 1
$goto loop
$
$done:
$close/nolog dir
$write sys$output tot, " files counted in ", num, " records."
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2008 07:43 AM
тАО10-31-2008 07:43 AM
Re: DCL get number of files in a directory
$ d = "[.kit]*.*;*"
$ cnt = -1
$ next: cnt = cnt + 1
$ x = f$search( d )
$ if f$length( x ) .gt. 0 then goto next
$ write sys$output cnt
Simple, clear, slow...
jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2008 01:37 AM
тАО11-06-2008 01:37 AM
Re: DCL get number of files in a directory
Define a symbol for awk
$ awk :== $ sys$common:[syshlp.examples.tcpip.snmp]gawk.exe
$ pipe dir/gr dsa2:[xxx.exp.yyy] | awk/comm="{if (/files./) print $(NF-1) }" sys$pipe
gives this number
The output of the
$ dir/gra ...
command gives several lines, we are interested in the line with the text
files.
and we want to print the last but one word of this line
$NF is the last word
$(NF-1) is the last but one word.