File Exchange

image thumbnail

absolutepath.m

version 1.0 (1.78 KB) by

Convert path representations.

4 Downloads

Updated

View License

ABSOLUTEPATH returns the absolute path relative to a given startpath.
    The startpath is optional, if omitted the current dir is used instead.
    Both argument must be strings.
 
    Syntax:
       abs_path = ABSOLUTEPATH( rel_path, start_path )

Comments and Ratings (4)

Eddie Frie

[pth,nm,ext]=fileparts(filein1);
curpath=pwd;
cd(pth)
full_path=pwd
cd(curpath)
% this is simple

Daniel

Daniel (view profile)

fails for absolute network paths like \\server\data

Jonathan Karr

Jonathan Karr (view profile)

Great work! I had the same comments as Bob; the function needed to be modified slightly to work on linux. See http://www.mathworks.com/matlabcentral/fileexchange/29768 for updated function.

Bob Henz

Did what I wanted with little modification but...

1) Shouldn't use lower() function because some systems are case sensitive.

2) Would be nicer if it handled filenames as well.

3) For PCs both '/' and '\' are valid dividers but this only considers filesep (which on PCs is '\') I know this is a PC vs Unix querkiness but might be better to actively convert all '\' AND '/' to the filesep character.

Updates

was wrong file

MATLAB Release
MATLAB 6.0 (R12)
Acknowledgements

Inspired: Coverage Report Generator, absolutepath

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video