필터 지우기
필터 지우기

Set Path's "Add with Subfolders" functionality

조회 수: 28 (최근 30일)
Matt Latourette
Matt Latourette 2021년 9월 3일
편집: Jan 2021년 9월 3일
When using the "Add with Subfolders" functionality in the Set Path window, MATLAB adds all of the subfolders of the folder specified by the user. However, it is often the case that there are subfolders that shouldn't be added to the path. Specifically, a .git, .hg, or .svn folder that is used for version control of MATLAB source code doesn't belong in the path and there are typically many subfolders within such a folder (typically one folder for every commit). Annoyingly, this creates a situation where one either has to go back to using "Add Folder" instead to individually add only the folders that you want on your MATLAB path or else use "Add with Subfolders" but then manually cleaning up afterward by selecting the .git folder and all of its subfolders and then clicking the "Remove" button. It would be nice if the "Add with Subfolders" command automatically recognized folders used by common version control systems and excluded them when adding to the path.
  댓글 수: 1
Bjorn Gustavsson
Bjorn Gustavsson 2021년 9월 3일
I've typically resigned to manually writing add_this_project.m-files where I add all the required subfolders to the path - it isn't too much work, but gives me full control over what goes where...

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2021년 9월 3일
편집: Jan 2021년 9월 3일
Create your own copy of genpath as mygenpath and insert e.g.:
...
if ~strcmp( dirname,'.') && ...
~strcmp( dirname,'..') && ...
~strncmp( dirname,classsep,1) && ...
~strncmp( dirname,packagesep,1) && ...
~strncmp( dirname, '.', 1) && ... % <-- no .git, .hg, .svn
~strcmp( dirname,'private')
Of course, when ignoring directories starting with a '.', you do not have to exclude '.' and '..' also.
Then add a folder with subfolders by:
addpath(mygenpath('D:\Your\Folder'), '-end')
Creating a GUI is easy also, and you can use pathtool as starting point.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Source Control에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by