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!