which('folderName') - Find the Location of a subdirectory of a directory
Mostra commenti meno recenti
Is there a simple way (better than brute force) to treat subdirectories as files and find the subdirectory which is highest on the matlab path?
i.e. if there exists a folder c:\Documents And Settings\user\My Documents\Matlab\myFolderName
whichOverload('myFolderName','dir')
%Should return c:\Documents And Settings\user\My Documents\Matlab\myFolderName
Note that parsing the path does not solve this immediately. The brute force way to do this would be something like
P = regexp(path,'[^;]+','match');
allItems = cellfun(@(x) dir(x),P,'UniformOutput',false);
matches = cellfun(@(x) ismember('myFolderName',{x.name}),allItems);
highestMatch = fullfile(P{find(matches,1)},'myFolderName');
But this is ugly and slow. . .
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Search Path in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!