How to get only foldername with uigetdir

94 次查看(过去 30 天)
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by