Show long path with ... in short label like 'D:\folder​\subfolder​\...\data'

Hello,
i'm using in a mlapp the function uigetdir to select folders for data storage and log files.
These folders are shown in the GUI, e.g.
C:\svn-work\projects\projectname\matlab\mytoolname\data
Is there an existing script, algorithm or function to short the displayed path, eg.
C:\svn-work\projects\...\data
Just asking before start coding by myself.
Thx

 Respuesta aceptada

How abou the following?
dirName = 'C:\svn-work\projects\projectname\matlab\mytoolname\data';
c = strsplit(dirName,'\');
dirNameShort = [strjoin(c(1:3),'\'),'\...\',c{end}];
The result is:
>> dirNameShort
dirNameShort =
'C:\svn-work\projects\...\data'

1 comentario

Tago
Tago el 11 de En. de 2019
Editada: Tago el 11 de En. de 2019
Hello Akira, looks good and is what i needed. Thx Stefan

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 11 de En. de 2019

Editada:

el 11 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by