Separate path string into drive and folders
이전 댓글 표시
Hi,
using fileparts brings the path, the name and the exentension of a fullfile (e.g., C:\user\files\myFile.txt). Is there a function that separates the path into drive and folders, so that drive = 'C:' folder1 = 'user' folder2 = 'files' ?
Thx, Philipp
채택된 답변
추가 답변 (2개)
Christian Schwermer
2018년 9월 9일
The shortest solution is to split the string using filesep as delimeter. filesep returns the platform-specific file separator "\" or "/".
pathparts = strsplit(s,filesep);
Dominique
2023년 7월 19일
path = uigetdir()
foldername = strsplit(path,"\");
foldername = foldername(end);
카테고리
도움말 센터 및 File Exchange에서 Filename Construction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!