Genpath is excluding package folders

4 vues (au cours des 30 derniers jours)
Matthew Brown
Matthew Brown le 18 Août 2017
Commenté : Walter Roberson le 23 Août 2017
Hello,
I am writing a script that requires to know every folder and subfolder, for which genpath() works perfectly.
However, there are a few folders that are packages (and begin with a '+'), and genpath ignores those.
Is it possible to have genpath include those, or some other way to automatically include that?
Thanks!
  1 commentaire
Walter Roberson
Walter Roberson le 23 Août 2017
No, it is not possible to set any flags or pass any options to genpath to cause it to return + directories: processing of them is hard-coded. genpath also removes @ directories.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 18 Août 2017
Try using dir() with double asterisks. See the help or my attached demo.
  2 commentaires
Matthew Brown
Matthew Brown le 23 Août 2017
Thanks, dir('**/*.m') does what I need it to do.
However, does that only work in 2016+? The code I am writing will need to be backwards compatible with versions back to 2012B.
Walter Roberson
Walter Roberson le 23 Août 2017
You can look in File Exchange for one of the several recursive directory functions, such as https://www.mathworks.com/matlabcentral/fileexchange/32226-recursive-directory-listing-enhanced-rdir

Connectez-vous pour commenter.

Plus de réponses (1)

Jan
Jan le 23 Août 2017

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by