what will be the query for calling a folder(by path) to do the following loop or anything?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Thara C.S
le 8 Déc 2018
Commenté : Walter Roberson
le 9 Déc 2018
what will be the query for calling a folder(by path) to do the following loop or anything?
0 commentaires
Réponse acceptée
Walter Roberson
le 8 Déc 2018
projectdir = 'path/to/the/folder';
dinfo = dir(projectdir);
dinfo( ismember({dinfo.name}, {'.', '..'}) ) = []; %get rid of . and ..
dinfo( [dinfo.isdir] ) = []; %get rid of subfolders if you want to
entries = fullfile(projectdir, {dinfo.name} );
numfiles = length(entries);
results = cell(numfiles, 1);
for K = 1 : numfiles
thisentry = entries{K};
% process information for thisentry
...
results{K} = ....
end
6 commentaires
Walter Roberson
le 9 Déc 2018
in what II posted above you would change newentry however is appropriate . the code i posted shows how to extract the base name the new20 part but excluding the extension and then shows saving to a different folder and with a different extension . You could easily instead do something like the same folder but with 'processed_' as a prefix or whatever is appropriate . fileparts to break the input name into parts then do appropriate string manipulation then put the result together into the output file name .
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur File Operations 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!