from
editall
by Matt Fig
Opens all M-files in directory for editing.
|
| editall(dir,varargin) %#ok
|
function [] = editall(dir,varargin) %#ok
%EDITALL opens all M-files in directory for editing.
% editall(dir) opens all M-files in directory dir for editing. If dir is
% not specified, the M-files in the current directory will be opened. The
% input argument must be a string. This function uses the what command.
%
% Examples
%
% editall
% editall('C:\Documents and Settings\Matlablover\Desktop')
% editall('..')
%
% The first example opens all M-files in the current directory. The second
% example opens all M-files in the specified directory; replace
% 'Matlablover' with your username on a windows machine. The third example
% opens all M-files in the directory above the current directory.
%
% See also pwd, cd, edit, what.
% Written by Matt Fig. email: popkenai@yahoo.com
switch nargin
case 0
% User wants to open M-files in the current directory.
lst = what(pwd);
case 1
% User wants to open M-files in a specified directory.
if ~ischar(dir)
error('Input argument must be a string. See help.')
end
lst = what(dir);
if isempty(lst)
error(['Unable to open: ''',dir,'''; it may not exist.'])
end
otherwise
% varargin used to contol the error message for too many arguments.
error('The number of input arguments must be 0 or 1. See help.')
end
if length(lst.m)<1
fprintf('\t%s\n',['No M-files found in: ''', lst.path,''''])
else
% Open all M-files in the directory with editor.
for ii = 1:length(lst.m)
edit([lst.path,'\',lst.m{ii}])
end
end
|
|
Contact us at files@mathworks.com