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

 채택된 답변

Akira Agata
Akira Agata 2019년 1월 11일
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

Tago
Tago 2019년 1월 11일
편집: Tago 2019년 1월 11일
Hello Akira, looks good and is what i needed. Thx Stefan

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Standard File Formats에 대해 자세히 알아보기

질문:

2019년 1월 11일

편집:

2019년 1월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by