how to get files name without format extension inside a folder
8 次查看(过去 30 天)
显示 更早的评论
i have a folder with many files with different extension.i need .txt format files name alone to be saved in a variable in matlab?
0 个评论
回答(1 个)
ES
2014-1-16
allTextFiles=dir('*.txt');;
number_of_files=length(allTextFiles);
Name_ofFile_1=allTextFiles(1).name;...
3 个评论
ES
2014-1-16
The variable you have used "nameoffile" can hold only one string. So when the for loop finishes, it will have the last filename only.. Use a cell instead.
path = 'C:\Users\test\';
listing = dir(fullfile(path, '*.txt'));
nof=length(listing);
for i=1:numel(listing)
nameoffile{i}=listing(i).name;
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!