-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenamemWRONGtoRIGHT.m
More file actions
51 lines (41 loc) · 1.3 KB
/
renamemWRONGtoRIGHT.m
File metadata and controls
51 lines (41 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function renamemWRONGtoRIGHT(A,B)
C = B;
wrongname = {'HEX','Dic'};
rightname = {'EGFP','DIC'};
for indi =1:length(wrongname)
wrongnamedir{indi} = strcat('*',wrongname{indi},'*.tif');
rightnamedir{indi} = strcat('*',rightname{indi},'*.tif');
end
E={B}; %beginning of file name for saving
channelstoinput = {'_mKate','_EGFP','_CFP','DIC'};
% channelstoinput = {'mKate','_EGFP','_CFP','_DIC'};
channelinputs = '(';
for i=1:length(channelstoinput)
if i ==1
channelinputs = strcat(channelinputs,channelstoinput{i});
elseif i < length(channelstoinput)
channelinputs = strcat(channelinputs,'|',channelstoinput{i});
else
channelinputs = strcat(channelinputs,'|',channelstoinput{i},')');
end
end
BACKdir = strcat(A,B,'\back');mkdir (BACKdir);
DIRone = strcat(A,B,'\',C);
cd(DIRone);
for indi = 1:length(wrongnamedir)
wnamedir = char(wrongnamedir{indi});
dirlist = dir(wnamedir);
cfile = {dirlist.name};
wname = char(wrongname{indi});
rname = char(rightname{indi});
% parfor i = 1:length(cfile)
for i = 1:length(cfile)
oldfilename = cfile(i);
oldfile = oldfilename{1};
[a,b] = regexp(oldfile,wname);
newfile = strcat(oldfile(1:a-1),rname,(oldfile(b+1:end)));
movefile(oldfile,newfile);
disp(i)
end
end
end