Separate path string into drive and folders
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (2)
Christian Schwermer
am 9 Sep. 2018
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
am 19 Jul. 2023
path = uigetdir()
foldername = strsplit(path,"\");
foldername = foldername(end);
Kategorien
Mehr zu Filename Construction finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!