Error using copyfile No matching files were found.

15 ビュー (過去 30 日間)
Dung Vu
Dung Vu 2019 年 11 月 15 日
回答済み: Dung Vu 2019 年 11 月 15 日
Dear Matlab users,
I'm very new in Matlab, what am I doing wrong? The tif-files are in the folder TimePoint_1 ... Can anyone help me out please?
% copy all tif files without thumb in filename to folder B
path1 ='C:\Users\rename_microscope_files\movie\2019-08-28\32534\TimePoint_1'
dest = 'C:\Users\rename_microscope_files\image_sorted'
source =fullfile(path1,'*.tif');
myfile= dir(source);
% loop over all files in the folder
for i = 1:numel(myfile)
idx = strfind(myfile(i).name,'_thumb');
if ~isempty(idx)
%do nothing
else
%copy to folder image_sorted
copyfile(myfile(i).name,dest)
end
end
Error using copyfile. No matching files were found.

採用された回答

Guillaume
Guillaume 2019 年 11 月 15 日
I'd replace
idx = strfind(myfile(i).name,'_thumb');
if ~isempty(idx)
%do nothing
else
by the simpler
if ~contains(myfile(i).name, '_thumb')
which does the required work inside the if.
The problem is that you only pass the filename of the source to copyfile so it looks for it in the current directory, not in path1. The fix is simple:
if ~contains(myfile(i).name, '_thumb')
copyfile(fullfile(path1, myfile(i).name), dest);
end

その他の回答 (1 件)

Dung Vu
Dung Vu 2019 年 11 月 15 日
Thank you very much, it's working!

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by