<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DCL get number of files in a directory in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297473#M44788</link>
    <description>If there is garantueed to be just 1 version, or less than 60 and you are only interested in the number of names, then you can use: $SEARCH/NOWARN/WIND=0/STAT x.dir WF*$$*78j23&lt;BR /&gt;For OpenVMS the SEARCH/STAT command will define DCL SYMBOL: SEARCH$RECORDS_SEARCHED&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;Picking up the count form DRIECTORY/GRAND using a pipe is probably the most efficient.&lt;BR /&gt;But you _could_ figure it out with DCL:&lt;BR /&gt;&lt;BR /&gt;$tot = 0&lt;BR /&gt;$num = 1&lt;BR /&gt;$open/read/share=write/error=done dir 'p1&lt;BR /&gt;$&lt;BR /&gt;$loop:&lt;BR /&gt;$read/end=done dir rec&lt;BR /&gt;$nam = f$cvui(3*8,8,rec)&lt;BR /&gt;$cnt = ( f$len(rec)  - nam - 4 ) / 8&lt;BR /&gt;$tot = tot + cnt&lt;BR /&gt;$num = num + 1&lt;BR /&gt;$goto loop&lt;BR /&gt;$&lt;BR /&gt;$done:&lt;BR /&gt;$close/nolog dir&lt;BR /&gt;$write sys$output tot, " files counted in ", num, " records."&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 31 Oct 2008 13:39:28 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2008-10-31T13:39:28Z</dc:date>
    <item>
      <title>DCL get number of files in a directory</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297470#M44785</link>
      <description>This is for DCL script.&lt;BR /&gt;&lt;BR /&gt;Is there a system function (Lexical/Lib/Services) to get the number of files in a directory like "$ DIR/GRAND directoryname" DCL command?  &lt;BR /&gt;&lt;BR /&gt;I'm trying to avoid having to write output of DIR/GRAND to a file and then extract the info.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 30 Oct 2008 16:39:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297470#M44785</guid>
      <dc:creator>Steven  Watson</dc:creator>
      <dc:date>2008-10-30T16:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: DCL get number of files in a directory</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297471#M44786</link>
      <description>&lt;!--!*#--&gt;No - but you can do something like this:&lt;BR /&gt;&lt;BR /&gt;$ pipe dir/grand |  sear sys$pipe " files." | -&lt;BR /&gt;( read sys$pipe x ; x = f$elem(5," ",x) ; defi/job x &amp;amp;x )&lt;BR /&gt;$ x = f$inte(f$trnl("x","lnm$job"))&lt;BR /&gt;$ show symbol x</description>
      <pubDate>Thu, 30 Oct 2008 17:05:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297471#M44786</guid>
      <dc:creator>Jim_McKinney</dc:creator>
      <dc:date>2008-10-30T17:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: DCL get number of files in a directory</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297472#M44787</link>
      <description>Concur with Jim.&lt;BR /&gt;&lt;BR /&gt;Here's why...&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2008 12:03:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297472#M44787</guid>
      <dc:creator>Richard W Hunt</dc:creator>
      <dc:date>2008-10-31T12:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: DCL get number of files in a directory</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297473#M44788</link>
      <description>If there is garantueed to be just 1 version, or less than 60 and you are only interested in the number of names, then you can use: $SEARCH/NOWARN/WIND=0/STAT x.dir WF*$$*78j23&lt;BR /&gt;For OpenVMS the SEARCH/STAT command will define DCL SYMBOL: SEARCH$RECORDS_SEARCHED&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;Picking up the count form DRIECTORY/GRAND using a pipe is probably the most efficient.&lt;BR /&gt;But you _could_ figure it out with DCL:&lt;BR /&gt;&lt;BR /&gt;$tot = 0&lt;BR /&gt;$num = 1&lt;BR /&gt;$open/read/share=write/error=done dir 'p1&lt;BR /&gt;$&lt;BR /&gt;$loop:&lt;BR /&gt;$read/end=done dir rec&lt;BR /&gt;$nam = f$cvui(3*8,8,rec)&lt;BR /&gt;$cnt = ( f$len(rec)  - nam - 4 ) / 8&lt;BR /&gt;$tot = tot + cnt&lt;BR /&gt;$num = num + 1&lt;BR /&gt;$goto loop&lt;BR /&gt;$&lt;BR /&gt;$done:&lt;BR /&gt;$close/nolog dir&lt;BR /&gt;$write sys$output tot, " files counted in ", num, " records."&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2008 13:39:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297473#M44788</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-10-31T13:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: DCL get number of files in a directory</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297474#M44789</link>
      <description>Or you can just count them...&lt;BR /&gt;&lt;BR /&gt;$ d = "[.kit]*.*;*"&lt;BR /&gt;$ cnt = -1&lt;BR /&gt;$ next: cnt = cnt + 1&lt;BR /&gt;$   x = f$search( d )&lt;BR /&gt;$   if f$length( x ) .gt. 0 then goto next&lt;BR /&gt;$ write sys$output cnt&lt;BR /&gt;&lt;BR /&gt;Simple, clear, slow...&lt;BR /&gt;&lt;BR /&gt;jon</description>
      <pubDate>Fri, 31 Oct 2008 14:43:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297474#M44789</guid>
      <dc:creator>Jonathan Cronin</dc:creator>
      <dc:date>2008-10-31T14:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: DCL get number of files in a directory</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297475#M44790</link>
      <description>Using awk is handy for such a job&lt;BR /&gt;&lt;BR /&gt;Define a symbol for awk&lt;BR /&gt;&lt;BR /&gt;$ awk :== $ sys$common:[syshlp.examples.tcpip.snmp]gawk.exe&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ pipe dir/gr dsa2:[xxx.exp.yyy] | awk/comm="{if (/files./) print $(NF-1) }" sys$pipe&lt;BR /&gt;&lt;BR /&gt;gives this number&lt;BR /&gt;&lt;BR /&gt;The output of the &lt;BR /&gt;$ dir/gra ...&lt;BR /&gt;command gives several lines, we are interested in the line with the text&lt;BR /&gt;files.&lt;BR /&gt;and we want to print the last but one word of this line&lt;BR /&gt;$NF is the last word&lt;BR /&gt;$(NF-1) is the last but one word.</description>
      <pubDate>Thu, 06 Nov 2008 09:37:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/dcl-get-number-of-files-in-a-directory/m-p/4297475#M44790</guid>
      <dc:creator>labadie_1</dc:creator>
      <dc:date>2008-11-06T09:37:04Z</dc:date>
    </item>
  </channel>
</rss>

