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.
see
>> help crap
and the accompanying published M-file for information and a few self-explanatory examples.
us (2021). crap: a pedestrian absolute folder/file path creator (https://www.mathworks.com/matlabcentral/fileexchange/16538-crap-a-pedestrian-absolute-folder-file-path-creator), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
karel, we do NOT have this problem; can you get in touch with me by email?
thanks
us
When you try crap with only one directory, for example:
crap('thisdir')
It will crash, because it can't find any /. The following code works, but is identical:
crap('thisdir/')
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,
Karel
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.
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.
us
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.