xdir.m – more powerful rdir.m

It offers the same syntax as rdir.m but differs in two major ways:

1) performs processing on pathnames from a list
2) supports relative paths in the wildcard expression

To demonstrate what the above means in practical terms, assume that you have the following hierarchy:

/A/x_A/c1_A
/A/foo/y_A/c2_A
/A/z_A/c2_A
/B/x_B/c1_B
/B/foo/bar/y_B/c2_B
/B/z_B/c2_B
...
/P/x_P/c1_P
/P/foo/bar/doo/y_P/c2_P
/P/z_P/c2_P

For some reason you already have a list of preselected c1 files. Now you want to find c2 files in the y subdirectory of those top-level directories from which the c1 files come from. With xdir.m you can do the following:

pathnames = {...}; % list of preselected c1 files
result = xdir(pathnames, '../**/y*/c2*');

Yesterday to achieve that we had to write a couple of lines of code. Not anymore.

One more remark – xdir.m uses / as file separator internally and provides output using /. It accepts input with both / and used as separator. So in my feeling, it is more convenient than rdir.m.

DOWNLOAD: xdir.zip

Leave a Reply

Your email address will not be published. Required fields are marked *