Recursive addpath

版本 1.6.0.0 (3.5 KB) 作者: Anthony Kendall
Recursively adds directories to MATLAB path, optionally ignores some
4.3K 次下载
更新时间 2009/11/4

查看许可证

This is a very simple function that will add all directories beneath a specified directory (or the current directory if none is specified), with the option to ignore a specified list of directories. Any directories that are ignored (for instance, '.svn' and 'CVS' if using version control) will not have their subdirectories added either.

This is a fast, very lightweight--and easily modifiable--function that should work on any platform (not tested explicitly). I use it to add the directory trees of toolboxes not stored in MATLAB's toolbox folder, as well as for modules checked out of SVN and CVS source control repositories.

Per reviewer suggestions and comments, this now ignores private directories, overloaded methods directories, and also hidden directories with no need to specify additional directories. It also accepts flags as in 'addpath' to place the directories at the beginning or end of the path.

An addition to this function (12/01/2008) is the ability for it to be run in 'reverse', recursively removing directories from the path. This capability can be very useful when working with multiple copies of a code repository, for instance. Also, I fixed a bug as mentioned by a reviewer that properly handles files without extensions.

Thanks to the extensive help of a user (Joe McDonnell), this function has been almost totally rewritten with better error detection, more efficient operation (much quicker run times, even for large directory trees), an extended debug mode that lists everything the function does, and better help. Also, now ignores the 'CVS' directories by default.

Another user (Jim) made a suggestion which resulted in a speed increase of approximately 3x in a moderate-sized directory tree (which should increase with larger sized trees). Also, a small change is made for Mac compatibility.

引用格式

Anthony Kendall (2024). Recursive addpath (https://www.mathworks.com/matlabcentral/fileexchange/21086-recursive-addpath), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Search Path 的更多信息
致谢

启发作品: genpath_exclude

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.6.0.0

Optimizations and Mac compatibility changes.

1.5.0.0

Extensive modifications to code, renamed variables, better input checking, error checking, a debug mode, more examples, better help.

1.4.0.0

Added new capability to recursively remove directories, fixed a small bug.

1.3.0.0

Made changes to reflect reviewer comments. Thanks!

1.0.0.0

Fixed small error in initial submission