--[[
 Delete empty directories in the same directory
 in which this file resides.
--]]

 local thisdir = (arg[0]):gsub ("%.[^%.]+$", "")
 local thispath = thisdir.."."
 local dirtype <const> = 0x1000
 local execute <const> in os
 local dir <const> in require "riscos"
 local empty = \ (d)
     local ok
     for o,t in dir (d) do
       if o then ok = true break end -- if
     end -- for
     => not ok
     end -- function
 local cmdlist, somedir = { }
 local del <const> = "delete %s"
 for leaf,ftype in dir (thisdir) do
   if ftype == dirtype then
      somedir = thispath..leaf
      if empty (somedir) then
        cmdlist[1 + #cmdlist] = del:format (somedir)
      end -- if
   end -- if
 end -- for
 for _,cmd in ipairs (cmdlist) do
  execute (cmd)
 end -- for
