How can I fix Error using files=dir command
7 次查看(过去 30 天)
显示 更早的评论
I upgraded MATLAB 2014 to 2018.
When I run the code, I get an error . please advise how ot fix this error.
This code (makeMaxProjections) helps me to run all the image files (either TIF or czi) in that directory.
>> makeMaxProjections('*', '.czi')
Error using dir
Characters adjacent to a ** wildcard must be file separators.
Error in makeMaxProjections (line 28)
files=dir(['*' fileString '*' ending]);
Please help me to fix the line 28 to run this cod ein 2018 version.
files=dir(['*' fileString '*' ending]);
0 个评论
回答(3 个)
Steven Lord
2018-11-16
In release R2016b we enhanced dir to be able to search recursively if the filename included two asterisks adjacent to one another. I suspect fileString is empty (or begins and/or ends with an asterisk) on that line of code. In that case, you'll probably want to modify your code to take advantage of this functionality as shown in the "Find Files in Subfolders" example on the dir documentation page.
0 个评论
Image Analyst
2018-11-17
Try this:
% Make sure ending starts with a dot.
if ending(1) ~= '.'
ending = ['.', ending]
end
if isempty(fileString)
filePattern = sprintf('*%s', ending)
else
filePattern = sprintf('*%s*%s', fileString, ending)
end
files=dir(filePattern)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!