フィルターのクリア

How to get only foldername with uigetdir

94 ビュー (過去 30 日間)
Jonas K
Jonas K 2017 年 6 月 27 日
コメント済み: Stephen23 2022 年 3 月 23 日
Hello, I want to select a folder (would be subfolder2 in my example) and use its name as a string. The problem is that not only the foldername but the whole location is the output of uigetdir().
name = uigetdir('./subfolder1/');
Is there a simple function to just get the name of the selected folder?
Cheers, J
  1 件のコメント
Guillaume
Guillaume 2017 年 6 月 27 日
But what if the user navigate to a completely different folder? Maybe not even on the same drive?

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2017 年 6 月 27 日
編集済み: Stephen23 2022 年 3 月 23 日
fp = uigetdir('./subfolder1/');
[~,name] = fileparts(fp)
  3 件のコメント
Carl Hopkins
Carl Hopkins 2022 年 3 月 23 日
change second line of text to:
[~name]=fileparts(filepath)
Stephen23
Stephen23 2022 年 3 月 23 日
@Carl Hopkins: fixed, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by