Borrar filtros
Borrar filtros

How to get only foldername with uigetdir

94 visualizaciones (últimos 30 días)
Jonas K
Jonas K el 27 de Jun. de 2017
Comentada: Stephen23 el 23 de Mzo. de 2022
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 comentario
Guillaume
Guillaume el 27 de Jun. de 2017
But what if the user navigate to a completely different folder? Maybe not even on the same drive?

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 27 de Jun. de 2017
Editada: Stephen23 el 23 de Mzo. de 2022
fp = uigetdir('./subfolder1/');
[~,name] = fileparts(fp)
  3 comentarios
Carl Hopkins
Carl Hopkins el 23 de Mzo. de 2022
change second line of text to:
[~name]=fileparts(filepath)
Stephen23
Stephen23 el 23 de Mzo. de 2022
@Carl Hopkins: fixed, thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by