public void AnalyseDirectory(String dir){
        File F = new File(dir);
        String[] fi = F.list();
        String of ;
        File fil = new File(dir + "/dist/");
        if(!fil.exists())
        {
            fil.mkdir();
        }
        for(String f : fi)
        {
            if(new File(f).isDirectory())
                continue;
            if(!f.endsWith(".res"))
                continue;
            of = dir + "/dist/" + f.substring(0,f.length()-4) + "_dist.txt";
            StreamedLinkSet L = new StreamedLinkSet(dir+"/"+f);
            LinkSetNode n;
            L.initTreeTraversal();
            Frequency Fr = new Frequency();
            Set<Integer> S = new HashSet<Integer>();
            System.out.println("Processing " + f);
            while((n=L.getNextInOrder()) != null)
            {
                Fr.addValue(n.w);
                S.add(n.w);
            }
            
            List<Integer> k = General.asSortedList(S);
            try 
            {
                FileWriter out = new FileWriter(of);
                System.out.println("Writing to: " + of);
                for(int i:k)
                {
                   out.write(i + " " + Fr.getCumPct(i) + " " + Fr.getPct(i) + " " + Fr.getCount(i) + " \n");
                }
                out.flush();
                out.close();
            } 
            catch (IOException ex) 
            {
                Logger.getLogger(LinkSetAnalyser.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }