title: delete all files except some in TCL
body: <p>I am in need of a small script that cleans all files and directories except a few from a two levels down in a certain directory (module).</p>
  
  <p>I am trying to get the following piece of TCL code to work:</p>
  
  <pre><code>proc add_module {module} {
      # Clean up old source IP-catalogs
      set clean_list [glob -nocomplain ${repo_dir}/src/pl/${module}/semi_top/*/*]
      set clean_exception_xci ${repo_dir}/src/pl/${module}/semi_top/*/*.xci
      set clean_exception_prj ${repo_dir}/src/pl/${module}/semi_top/*/*.prj
      foreach clean_file ${clean_list} {
          if {{$clean_file} ne {$clean_exception_xci}} and {{$clean_file} ne {$clean_exception_prj}} {
              file delete -nocomplain $clean_file
          }
      }
  }
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <pre><code>invalid bareword "clean_file"
  in expression "clean_file ne clean_exception_xci";
  should be "$clean_file" or "{clean_file}" or "clean_file(...)" or ...
      (parsing expression "clean_file ne clean_ex...")
      invoked from within
  "if {clean_file ne clean_exception_xci} and {clean_file ne clean_exception_prj} {
          file delete -nocomplain clean_file
      }"
      ("foreach" body line 2)
      invoked from within
  "foreach clean_file ${clean_list} {
      if {clean_file ne clean_exception_xci} and {clean_file ne clean_exception_prj} {
          file delete -nocomplain clea..."
      (procedure "add_module" line 37)
      invoked from within
  </code></pre>
  
  <p>Could anyone please give me a hint of what might be going on? (I figure the code would only deal with files, not directories. Someting probably have to be added to deal with directories as well...)</p>
  
  <p>Thanks! /Teddy</p>