Is there a way to create a new project from a list of files, such that the files are automatically grouped by directory?

My problem is that I have a fairly large project directory tree, which I normally edit by typing "mate ." on the command line. That does exactly what I want, except that it includes every file in the tree, not just source files. Assuming it's not a clean directory to start with I get a lot of binary files.  I've set up filters to eliminate obvious non-source extensions such as *.o, *.so, etc. but I can't filter out the names without extensions (such as the names of compiled executables).  Also, some of the intermediate files have the same extensions as the source files. For instance, the Pyrex compiler produces *.c files to pass to the C compiler.  I may have real source *.c files in with the *.pyx files, and I don't want to see the intermediate *.c files in the project listing. (More to the point, I don't want "Find in Project..." to bother searching them!)

Since this is all in SVN I can easily get a list of true source files via the 'svn ls -R' command.  But how do I get that list into TextMate?  I've tried 'mate `svn ls -R`', and it *almost* does what I want.  Unfortunately the files aren't grouped by directory. Even more unfortunately, since the svn command lists directories under its control as well as files , I get two copies of each file in the project list: One at the top-level as explicitly given, and one at a sub-level when its containing directory is explicitly given.  So a directory tree like:

top/
  foo.c
  bar.c
  subdir/
    baz.c
    qux.c

...ends up giving me a project containing "foo.c, bar.c, baz.c, qux.c" at the top level, along with a "subdir" grouping which contains "baz.c" and "qux.c".  I want the project groupings to exactly mirror the directory structure.

Ideas?  I can easily write a script to post-process the output of 'svn ls -R', as long as I know what sort of list will make TextMate happy.  I'm trying to avoid having to output a full-blown XML *.tmproj file, but I'm afraid that's what it's going to come down to.

--
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com