Can I get 'H:\' (not 'H:\\')from FULLFILE?

5 views (last 30 days)
Mark
Mark on 18 Feb 2016
Commented: Image Analyst on 29 Apr 2016
In Matlab R2015b (Windows), FULLFILE('H:','\') returns 'H:\\' with a double-backslash, which raises bugs in our code. Older versions (e.g. R2010b) returned 'H:\' with the correct single-backslash. How do I get 'H:\' from FULLFILE?

Answers (2)

Jan
Jan on 18 Feb 2016
This is a bug in fullfile. While this works correctly:
fullfile('H:\Folder\', filesep)
% 'H:\Folder\'
this is wrong:
fullfile('H:\', filesep)
% 'H:\\'
I'm using this replacement: FEX: JoinPath . You could store this in a folder, which is located before the toolboxes of Matlab in the PATH, and call it "fullfile.m". But I hesitate to shadow built-in functions.

Image Analyst
Image Analyst on 29 Apr 2016
This also occurs in R2016a.
Don't even use \ (backslash). Forward slash / works just fine in Windows, as well as Linux. Why are you still using backslash?
  2 Comments
Mark
Mark on 29 Apr 2016
>> fullfile('H:','/')
ans = H:\\
>>
Image Analyst
Image Analyst on 29 Apr 2016

Perhaps it is a bug.

If you know your second path part is a single slash, then just hard code it

folder = 'H:/';

Sign in to comment.

Categories

Find more on Filename Construction in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!