File Exchange

image thumbnail


version 1.5 (3.03 KB) by

This is an enhancement to MATLAB's dir function, for dealing with sequentially numbered files.



View License

This function is designed for dealing more easily with filenames. It is particularly useful for locating files with a numerical suffix, as might be used for data files that are sequentially numbered. In addition to the fields of dir, it also returns a path field and a number field. It also allows for executing functions whose input is a filename. Examples are open, delete, ...

Type help new_dir to find examples.

Comments and Ratings (3)

Jan Simon

Jan Simon (view profile)

Bugs are fixed, descriptive warning on Windows for the -find flag, updated description on the FEX page (removed "Matlab 5.3"), considering directories, some improvements in the help section. No comments in the source. Useful and usable.

Jan Simon

Jan Simon (view profile)

The function starts with overwriting VARARGIN - please remove this!
The help section now mentions, that the -find option works on Unix only. But a check in the function (if ~isunix, error('-find works on Unix only'); end) would be useful.
Please update the file information on the FEX: This function does still not run under Matlab 5.3.
The help section is still hard to read (for me) due to the formatting. A H1-line would be helpful (see LOOKFOR command).
Some simplifications are possible, e.g.: "numel({})" equals "numel(d)",
"to_do = strncmp( varargin, '-', 1 );
neg_queery = ~to_do&strncmp(varargin, '~', 1 );" is easier as: "neg_queery = strncmp(varargin, '~', 1);".
Comments in the source are recommended generally.
I really like the idea of expanding DIR with a filter for numerical indices.

Jan Simon

Jan Simon (view profile)

In contrary to the file informations above, new_dir does not run on Matlab 5.3.1 (and 6.5 also), because the DIR command does not reply the field 'datenum' for this versions.
No meaningful H1 line, the help text is long and exhaustive, but hard to read (please insert a space after the %, limit the line width, use some empty lines to divide sections). A lot of examples are given, but some crash: There is no "-regexp" flag for the FIND command of Windows XP --- perhaps your function is written for Unix only?! If so, please mention this.
No comments in the source. The initial section for debugging is useless for FEX users.
If updates of this files are submitted or searched, it is helpful to mention the full name of the author and the exact date of submission.
Working partially on WindowsXP, but not under the claimed Matlab version.



Improvement for handling errors


Bug fix, and added the option to restrict search to directories or non-directories.


Thanks for the comment Jan. I fixed the varargin bug (it was just an oversight), and adopted your other suggestions.


Bugs have been fixed, and examples are much easier. to get started create a test directory by typing "new_dir -generate", and follow the examples in help new_dir.

MATLAB Release
MATLAB 7 (R14)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video