File size distribution: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added the REXX computer programming language.)
m (→‎{{header|REXX}}: added a summary (totals).)
Line 417: Line 417:
@.=00 /*stemmed array to hold record counts. */
@.=00 /*stemmed array to hold record counts. */
g=0 /*number of good records found (so far)*/
g=0 /*number of good records found (so far)*/
do while lines(dirOut) \== 0
$=0; do while lines(dirOut) \== 0
$=linein(dirOUT); if left($, 1)==' ' then iterate /*process data. */
_=linein(dirOUT); if left(_, 1)==' ' then iterate /*process data. */
parse upper var $ dat tim sz . /*uppercase suffix*/
parse upper var _ dat tim sz . /*uppercase suffix*/
if pos('/', dat) ==0 | pos(":", tim)==0 then iterate /*validate dat&tim*/
if pos('/', dat) ==0 | pos(":", tim)==0 then iterate /*validate dat&tim*/
if pos(',', sz) \==0 then sz=space( translate(sz, , ","), 0) /*SZ has commas? */
if pos(',', sz) \==0 then sz=space( translate(sz, , ","), 0) /*SZ has commas? */
Line 427: Line 427:
sz=# * 1024 **pos(sfx,'KMGT')/1 /*compute true val*/
sz=# * 1024 **pos(sfx,'KMGT')/1 /*compute true val*/
end
end
$=$ + sz /*keep a running total for the filesize*/
if sz==0 then L=0 /*handle special case for an empty file*/
if sz==0 then L=0 /*handle special case for an empty file*/
else L=length(sz) /*obtain the length of filesize number.*/
else L=length(sz) /*obtain the length of filesize number.*/
Line 451: Line 452:
end /*k*/
end /*k*/
end /*y*/
end /*y*/
say
/*stick a fork in it, we're all done. */
'ERASE' dirOut /*perform clean─up (erase a work file).*/</lang>
'ERASE' dirOut /*perform clean─up (erase a work file).*/
say g ' files detected,' $ " total bytes." /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default input: &nbsp; (which in this case was the &nbsp; '''C:''' &nbsp; drive.)}}
{{out|output|text=&nbsp; when using the default input: &nbsp; (which in this case was the &nbsp; '''C:''' &nbsp; drive.)}}
<pre>
<pre>
Line 468: Line 470:
10^8 ──► 10^9 -1 3 ─
10^8 ──► 10^9 -1 3 ─
10^9 ──► 10^10 -1 1 ─
10^9 ──► 10^10 -1 1 ─

55537 files detected, 12656297888 total bytes.
</pre>
</pre>