enable utils compilation.
[AROS-Contrib.git] / rexx / progs / exts.r
blob0166605d18956bbb8aa8bdf087104d9b00b763fb
1 /* exts.r, displays all extensions (+info) in a directory */
2 /* Bill N. Vlachoudis (c) May 1996 */
3 if arg(1) = "?" then do
4 say "syntax: exts [<dir>]"
5 say "desc: Displays a summary of file extensions in the current directory"
6 say "author: Bill N. Vlachoudis"
7 say "date: May 1996"
8 exit
9 end
10 parse source system .
11 if system == "UNIX" then
12 'ls -l' arg(1) '(stack'
13 else do
14 'dir' arg(1) '(stack'
15 /* skip first lines */
16 c = 0
17 do while queued()>0
18 parse pull line
19 if line="" then c=c+1
20 if c=2 then leave
21 end
22 end
23 size. = 0
24 count. = 0
25 exts = ""
26 totsize = 0
27 files = 0
28 maxtype = 0
29 do while queued()>0
30 if system=="UNIX" then
31 parse pull . . . . size . . . name '.' type .
32 else do
33 parse pull name type size fdate ftime
34 if ftime = '' then do
35 size = type
36 type = 'No_EXT' /* file has '*. ' type of name */
37 end
39 if type = "file(s)" then do
40 do queued()
41 parse pull .
42 end
43 leave
44 end
45 if type="<DIR>" then iterate
46 p = pos(',',size)
47 do while p>0
48 size = delstr(size,p,1)
49 p = pos(',',size)
50 end
51 if datatype(size) ^= "NUM" then iterate
52 end
53 if datatype(size,'NUM') then do
54 if type="" then type="(none)"
55 size.type = size.type + size
56 count.type = count.type + 1
57 totsize = totsize + size
58 files = files + 1
59 if count.type = 1 then exts = exts type
60 maxtype = max(maxtype,length(type))
61 end
62 end
63 maxtype = maxtype + 3
64 line=left("Extensions",maxtype) " Files" right("Size",10)
66 say line
67 say copies('-',length(line))
68 do i = 1 to words(exts)
69 type = word(exts,i)
70 say left(type,maxtype) format(count.type,6) format(size.type,10)
71 end
73 say copies('-',length(line))
74 say words(exts) "Extensions, " files "Files"
75 say "Total Size =" totsize"."