Recursive addpath

Recursively adds directories to MATLAB path, optionally ignores some

Ahora está siguiendo esta publicación

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.

Citar como

Anthony Kendall (2026). Recursive addpath (https://es.mathworks.com/matlabcentral/fileexchange/21086-recursive-addpath), MATLAB Central File Exchange. Recuperado .

Agradecimientos

Inspiración para: genpath_exclude

Categorías

Más información sobre Search Path en Help Center y MATLAB Answers.

Información general

Compatibilidad con la versión de MATLAB

  • Compatible con cualquier versión

Compatibilidad con las plataformas

  • Windows
  • macOS
  • Linux
Versión Publicado Notas de la versión Action
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