File Exchange

image thumbnail

crap: a pedestrian absolute folder/file path creator

version (8.57 KB) by us
crap creates absolute paths to folders and/or files

1 Download

Updated 30 Jan 2008

View License

CRAP creates clean absolute paths (including UNCs) for existing
- absolute paths to folders and/or files
- relative paths to folders and/or files
which may include any valid combination of './' and/or '../' syntax.

this shall help to overcome some of the notorious problems with ML’s handling of relative folder/file names.

>> help crap
and the accompanying published M-file for information and a few self-explanatory examples.

Cite As

us (2021). crap: a pedestrian absolute folder/file path creator (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Urs (us) Schwarz

karel, we do NOT have this problem; can you get in touch with me by email?

Karel Crombecq

When you try crap with only one directory, for example:
It will crash, because it can't find any /. The following code works, but is identical:

Because I don't know which format the user will use to input the directory of choice, I can't use this utility until this problem is resolved.

Thanks for the good work,

Dietrich Lueerssen

With the change Urs had introduced, the function now handles all the cases I normally deal with. From my point of view, the function is well programmed and documented. In addition, this is a neat example how java code can be incorporated into MATLAB (in case you are curious). Urs' response time to the suggestion was better than my new review, so I can only say: well done, keep up the good work!

Thank you.

Urs (us) Schwarz

a new version, which preserves the leading back-slashes in UNC paths, has been uploaded and should be available soon. thanks to dietrich for bringing up this problem.

Dietrich Lueerssen

This is almost exactly what I need for a particular problem. It works fine, except in a case that I have quite often. If the file resides on a Windows file server (accessed through a UNC-type pathname such as \\Server\Folder\File.ext), then CRAP does not recognize the file's existence.

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!