Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the path part of a filename?

I want to get the path part of a file name in MATLAB like dirname and basename in Linux. I've tried to turn to find a function like strrchr, but I failed. I know strtok, strfind and textscan can be used, but I want to accomplish this with not more than two statements.

like image 871
Yantao Xie Avatar asked Jan 23 '13 09:01

Yantao Xie


Video Answer


1 Answers

For this particular problem I suggest you use the fileparts function:

[path, filename, extension] = fileparts(str)
like image 60
Nick Avatar answered Sep 29 '22 19:09

Nick