title: tcl deep recursive file search, search for files with *.c extension
body: <p>Using an old answer to search for a file in tcl:
  <a href="https://stackoverflow.com/a/435094/984975">https://stackoverflow.com/a/435094/984975</a></p>
  
  <p>First lets discuss what I am doing right now:
  Using this function:(credit to Jacson)</p>
  
  <pre><code># findFiles
  # basedir - the directory to start looking in
  # pattern - A pattern, as defined by the glob command, that the files must match
  proc findFiles { basedir pattern } {
  
      # Fix the directory name, this ensures the directory name is in the
      # native format for the platform and contains a final directory seperator
      set basedir [string trimright [file join [file normalize $basedir] { }]]
      set fileList {}
  
      # Look in the current directory for matching files, -type {f r}
      # means ony readable normal files are looked at, -nocomplain stops
      # an error being thrown if the returned list is empty
      foreach fileName [glob -nocomplain -type {f r} -path $basedir $pattern] {
          lappend fileList $fileName
      }
  
      # Now look for any sub direcories in the current directory
      foreach dirName [glob -nocomplain -type {d  r} -path $basedir *] {
          # Recusively call the routine on the sub directory and append any
          # new files to the results
          set subDirList [findFiles $dirName $pattern]
          if { [llength $subDirList] &gt; 0 } {
              foreach subDirFile $subDirList {
                  lappend fileList $subDirFile
              }
          }
      }
      return $fileList
   }
  </code></pre>
  
  <p>And calling the following command:</p>
  
  <pre><code>findFiles some_dir_name *.c
  </code></pre>
  
  <p>The current result:</p>
  
  <pre><code>bad option "normalize": must be atime, attributes, channels, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable
  </code></pre>
  
  <p>Now, if we run:</p>
  
  <pre><code>glob *.c
  </code></pre>
  
  <p>We get a lot of files but all of them in the current directory.</p>
  
  <p>The goal is to get <em>ALL</em> the files in <em>ALL</em> sub-folders on the machine with their paths.
  Anyone who could help?</p>
  
  <p>What I really want to do is find the directory with the highest count of *.c files.
  However, if I could list all the files and their paths, I could count, how many files are in each directory and get the one with the highest count.</p>