Selecting .tif files from a folder and copy them to another folder
9 views (last 30 days)
Show older comments
Hi!
I have these 34 days folders and each folder contains 3 images (.tif) files. I want to select all these .tif files and copy them to another folder named "All_tif_images".

I wrote down this code but it is not working. Can anyone please tell me what's wrong with the code? Any feedback will be much appreciated!
clear all; close all; clc;
HOME = '/Users/aahmed78/PhD/Data/SWOT/Beaufort Gyre - CalVal/May2015';
day = [1:34];
foldername = 'All_tif_images';
for zz=1:size(day,2)
cd(strcat(HOME,'/Day ',num2str(day(zz))))
file_list = dir('*.tif');
filenumber = length(file_list);
for i = 1:filenumber
filename = file_list(i).name;
cd('..');
copyfile(filename,cd(strcat(HOME,'/All_tif_images')));
end
end
0 Comments
Accepted Answer
Voss
on 10 Apr 2022
clear all; close all; clc;
HOME = '/Users/aahmed78/PhD/Data/SWOT/May2015';
foldername = 'All_tif_images';
foldername = fullfile(HOME,foldername);
file_list = dir(fullfile(HOME,'Day*','*.tif'));
for ii = 1:numel(file_list)
filename = fullfile(file_list(ii).folder,file_list(ii).name);
copyfile(filename,foldername);
end
More Answers (0)
See Also
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!