user1871118
user1871118

Reputation: 11

uigetfile not pulling entire file name

I'm using uigetfile to upload my data. I've time stamped my data with a date. So a file I want to upload looks like Data-Dec01_11/45/35.txt The problem is uigetfile reads till the first "/" and then assumes that that is the end of the file name. Thus it pulls the file name Data-Dec01_11. But of course when I load that file it doesn't exist. How do I force uigetfile to pull the entire file name?

Upvotes: 1

Views: 184

Answers (1)

Digna
Digna

Reputation: 882

You cannot use slashes or backslashes in your file names, as they can be mistaken with the file separator, as in your case.

You can use ´regexpr´ to rename your files so they do not contain illegal characters, as explained in this trhead.

I copy here the code they suggest for your convenience (I've just added a slash and a backslash to the example string so you can see the results):

% these characters are allowed
  legalchars = 'a-zA-Z0-9\-\ \_\.' ;
% illegal filename
  A = 'Some@charac\ters$are(not&allowed/.txt'
% replace every other character with an underscore
  B = regexprep(A,['[^' legalchars ']'],'_')

Upvotes: 4

Related Questions