Hi everyone,
this will be a complex task.
I have following structure of folder and subfolders: starting with "movie":
Timepoint_1 many tif-files ...
2019_1 3245 Timepoint_2 *.tif
Timepoint_3 *.tif
Timepoint_4 tif-files ...
movie 2019_2 3245 Timepoint_5 *.tif
Timepoint_6 *.tif
Timepoint_7 tif-files ...
2019_3 3245 Timepoint_8 *.tif
Timepoint_9 *.tif
In all Timepoint_x folders are many tif-files. I want to:
- loop over all folders and subfolders to find all tif-files
- copy to another folder and
- rename them by
- sorting them in new folders with specific name scheme
How can I loop over all folders and subfolders till the function finds the tif files in a smart way? There are many existing functions to loop over subfolders. But I neither undertand nor even use them.
How can I combine the missing task with my existing code?
aim:
3_2_1_RFP_1.tif
3_2_1 3_2_1_RFP_10.tif
3_2_1_CFP_13.tif
image_sorted
3_2_1_RFP_1.tif
3_2_2 3_2_2_RFP_2.tif
3_2_2_YFP_2.tif
outputFolder = fullfile(pwd, 'image_sorted')
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end
path1 ='C:\Users\Desktop\rename_microscope_files\movie\2019_1\3245\TimePoint_1'
dest = 'C:\Users\Desktop\rename_microscope_files\image_sorted'
source =fullfile(path1,'*.tif');
myfile= dir(source);
for i = 1:numel(myfile)
if ~contains(myfile(i).name, '_thumb')
copyfile(fullfile(path1, myfile(i).name), dest);
end
end
for i = 1:size(file_names)
fname = file_names(i).name;
fname = strsplit(fname,'_');
fname = char(fname);
row = fname(1);
col = str2num(fname(2:3));
switch row
case 'A'
row = 1;
case 'B'
row = 2;
case 'C'
row = 3;
case 'D'
row = 4;
case 'E'
row = 5;
case 'F'
row = 6;
case 'G'
row = 7;
case 'H'
row = 8;
end
switch wave
case 'w1'
wave = RFP;
case 'w2'
wave = YFP;
case 'w3'
wave = CFP;
end
new_fname_info(i).row = row;
new_fname_info(i).col = col;
new_fname_info(i).site = 1;
new_fname_info(i).org_fname = file_names(i).name;
new_fname_info.channel = wave;
new_fname_info.timepoint = -1;
end
0 Comments
Sign in to comment.