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:7FilesNames(i,j)=strread('fileList{i,1}', '%s %s %s %s %s %s %s', 'delimiter', '\\');endend
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?
Best Answer