Code covered by the BSD License  

Highlights from
realpath

4.66667

4.7 | 3 ratings Rate this file 0 Downloads (last 30 days) File Size: 1.46 KB File ID: #8680

realpath

by M MA

 

07 Oct 2005 (Updated 10 Oct 2005)

Absolute pathname.

| Watch this File

File Information
Description

Resolves relative paths and extra filesep characters in the input.

Syntax:
OUTPUT = REALPATH(THEPATH)

where THEPATH is the path to a file or folder, which should exist.

Example:
realpath('../myfile.txt');
% returns /home/user/whatever/myfile.txt

Acknowledgements
This submission has inspired the following:
realpath
MATLAB release MATLAB 6.0 (R12)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
30 Mar 2006 I Stoddard

Fixed a 6.5/7.1 compatibility hassle for me....

04 Jan 2008 Jason X.

Very helpful. I propose a revision:

if exist(thePath,'dir') == 7 && ~isempty(dir(thePath))
...

==>

isd = fileattrib(thePath);
if isdir(thePath) && isd
...

because 'dir' might be very slow, e.g. when there are lots of files in directory 'thePath'.

12 Jan 2010 Anthony Corr  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
path M MA 22 Oct 2008 08:02:28
directories M MA 22 Oct 2008 08:02:28
files M MA 22 Oct 2008 08:02:28
pathname M MA 22 Oct 2008 08:02:28
absolute M MA 22 Oct 2008 08:02:28
real M MA 22 Oct 2008 08:02:28
utilities M MA 22 Oct 2008 08:02:28

Contact us at files@mathworks.com