How do I create a table from the names of files in some folders?

23 ビュー (過去 30 日間)
Gabriel Ribeiro
Gabriel Ribeiro 2019 年 7 月 8 日
回答済み: Harley Calvert 2021 年 11 月 13 日
I have a big folder "Music", with N subfolders "Pop", "Rock", etc. Each folder has a couple of .flac songs.
I want to create a table in matlab which encodes all this information: it would have four columns (Genre, Artist, Song, Filename) and one row by song.
How could a create such table without doing it by hand?

回答 (2 件)

Rik
Rik 2019 年 7 月 8 日
You can use the dir function to get a full file list:
list=dir('C:\Your\Path\**\*.flac');
Then you can parse each file name to a table entry. The fileparts function is probably going to be useful here to extract folder names from the dir output.

Harley Calvert
Harley Calvert 2021 年 11 月 13 日
I did something like this:
filelist = dir('C:\Your\Path\**\*.flac');
filenames = cell(length(filelist),2);
for i = 1:length(filelist)
filenames(i,1) = {num2str(i)};
filenames(i,2) = {filelist(i).name};
end
disp(table(filenames))

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by