How can I decide the next problem?
Show older comments
I want to rename files in a directory. I have a cell variable named fileList after using this script:
function fileList = getAllFiles(dirName)
dirData = dir(dirName);
dirIndex = [dirData.isdir];
fileList = {dirData(~dirIndex).name}';';
if ~isempty(fileList)
fileList = cellfun(@(x) fullfile(dirName,x),...
fileList,'UniformOutput',false);
end
subDirs = {dirData(dirIndex).name};
validIndex = ~ismember(subDirs,{'.','..'});
for iDir = find(validIndex)
nextDir = fullfile(dirName,subDirs{iDir});
fileList = [fileList; getAllFiles(nextDir)];
end
end;
Files` names are: D:\20140210_test\Experiment1\ExpData_1_1.exp
I need files` names such as: 20140210.test.ExpData_1_1.exp
But I have problem with function strread. When I type:
FilesNames=[];
for i=1:length(fileList)
for j=1:7
FilesNames(i,j)=strread('fileList{i,1}', '%s %s %s %s %s %s %s', 'delimiter', '\\');
end
end
the error is:
Error using dataread Number of outputs must match the number of unskipped input fields.
Error in strread (line 51) [varargout{1:nlhs}]=dataread('string',varargin{:});
What can I do to avoid this one?
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!