Movefile doesn't work
이전 댓글 표시
Hi, I am trying to move files with specific filename into a new folder. Files that will be moved into new folder are selected based on interval values from other column.
The filename selection is worked but somehow the movefile doesn't read the filename. Here is my code:
fid = fopen ('Distiller.log','r')
skip = 29;
for ii = 1:skip-1
fgetl(fid);
end
line = fgetl(fid);
data = []
while (~isempty(line));
line =fgetl(fid);
line = regexprep(line, [^0-9\s+-.eE]','')
data = [data; str2num(line)];
end
sz=size(data);
num_sz=[1:(sz(1,1))]';
final_data=[data num_sz];
a=final_data(final_data(:,5)>372 & final_data(:,5)<=374,:)
a_str=num2str(A(:,6));
str_final_all=strcat(a_str,'.tif');
str_final_all_2=cellstr(str_final_all);
old = 'E:\Uji Coba\Image_seq\uji24april\Renamed';
new = 'E:\Uji Coba\Image_seq\uji24april\Selected';
mkdir(new)
for k=1:numel(str_final_all_2);
movefile(fullfile(old,str_final_all_2{k}), new);
end
The error is "No matching files were found" - "movefile(fullfile(old,str_final_all_2{k}), new)
I don't understand the error because the variabel for str_final_all_2 contains selected filenames

What is the solution?
Thank you very much
댓글 수: 2
Works for me
Maybe its a filesystem privilege issue?
I had similar issues with matlab not being able to move stuff on my desktop or my documents. My local user obviously has the privileges to do that, but Matlab might not.
Try copying the files to a subfolder of the root folder your matlab is working on, where it will clearly have the privilege to write to the file system, then run your script again. If it works, you will know that is the problem.
Walter Roberson
2018년 11월 25일
At the moment we as onlookers have no reason to expect that 146.tif exists in that directory . perhaps you could show us the output of
ls(old)
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!