Relative Filename

版本 1.9.0.0 (5.0 KB) 作者: Kesh Ikuma
A pair of M-files to convert between full and relative filenames.
714.0 次下载
更新时间 2013/11/4

查看许可证

RELFILE(FILE,PATH) converts full filename FILE to a relative filename with respect to PATH.

REL2FULLFILE(RELFILE,PATH) converts relative filename RELFILE to full filename using PATH as the base path.

Examples:

relfile('C:\Program Files\MATLAB\R2009a\bin\matlab.exe','C:\Program Files\MATLAB\R2009a')

returns '.\bin\matlab.exe' and

rel2fullfile('.\bin\matlab.exe','C:\Program Files\MATLAB\R2009a')

gets the original path back.

relfile('C:\Program Files\MATLAB\R2009a\bin\matlab.exe','C:\Program Files\MATLAB\R2009a\toolbox\matlab')

returns '..\..\bin\matlab.exe' and

rel2fullfile('..\..\bin\matlab.exe','C:\MATLAB\toolbox\matlab')

expands to 'C:\MATLAB\bin\matlab.exe'

Note on OS Compatibility:
Although these functions are written to be OS independent, they have been only tested under Windows. Please report here if you successfully used these functions under Linux or Mac.

引用格式

Kesh Ikuma (2024). Relative Filename (https://www.mathworks.com/matlabcentral/fileexchange/25701-relative-filename), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 File Name Construction 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.9.0.0

- fixed a bug in RELFILE (erred out if FILE was a cellstr)

1.8.0.0

bug fix in relfile.m

1.7.0.0

fixed the bug reported by igor

1.6.0.0

Another little mistake corrected...

1.4.0.0

Corrected last-minute mistakes in previous submission

1.2.0.0

Complete revamp of the codes, fixing a few bugs along the way.

1.1.0.0

Added support for FILE given as a cellstr array, allowing multiple conversions with 1 call

1.0.0.0