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!