フィルターのクリア

Files name from folder into string array

47 ビュー (過去 30 日間)
Turimo
Turimo 2022 年 6 月 13 日
回答済み: Nitanshu 2022 年 6 月 13 日
Hello,
Is it possible to retrieve file name from a folder and put them into a string array.
Manualy i can do this for a 10x1 string array but how to do it automatically :
dataFile = (["Label\Label_1.png";"Label\Label_10.png";"Label\Label_2.png";"Label\Label_3.png";"Label\Label_4.png";"Label\Label_5.png";"Label\Label_6.png";"Label\Label_7.png";"Label\Label_8.png";"Label\Label_9.png";])
dataFile = 10×1 string array
"Label\Label_1.png" "Label\Label_10.png" "Label\Label_2.png" "Label\Label_3.png" "Label\Label_4.png" "Label\Label_5.png" "Label\Label_6.png" "Label\Label_7.png" "Label\Label_8.png" "Label\Label_9.png"
I dont mind the 10 being second but if you have a workaround, why not.
Thank you

回答 (1 件)

Nitanshu
Nitanshu 2022 年 6 月 13 日
Hi,
Probably you could define a directory instance with directory path and get the file names under the name property and once the filenames are extracted you can manipulate it as you wish.
Hope it helps.
directory_instance = dir('directory_name');
file_names = {directory_instance.name};

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by