-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain1.m
66 lines (60 loc) · 2.01 KB
/
main1.m
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%%%综合2 修正文件名称并验证
clear;clc;
folder_name_all = uigetdir('');%选择文件夹
%%
filepathlist = dir(folder_name_all);
diary 'log1201.txt'
disp(' ');
time=clock;
t1=strcat(num2str(time(1)),'年',num2str(time(2)),'月',num2str(time(3)),'日',num2str(time(4)),':',num2str(time(5)));
disp(['北京时间:',num2str(t1),'开始记录']);
for j=3:length(filepathlist)
tic;
a=filepathlist(j).name;
subfilepathlist = dir(strcat(folder_name_all,'\',a));
for i=3:length(subfilepathlist)
b=subfilepathlist(i).name;
F=strfind(subfilepathlist(i).name,' ');
if isempty(F)
%continue; %continue会直接进入下一个循环,不会执行下面的语句
else
d=strrep(subfilepathlist(i).name,' ','');
linshi1=strcat(folder_name_all,'\',a,'\',b);
linshi2=strcat(folder_name_all,'\',a,'\',d);
movefile(linshi1,linshi2);
b=d;
end
subsublist=dir(strcat(folder_name_all,'\',a,'\',b));
d=subsublist(3).name;
img_path_list = dir(strcat(folder_name_all,'\',a,'\',b,'\',d,'\','*.dcm'));
c=numel(img_path_list);
oldname=strcat(folder_name_all,'\',a,'\',b);
newname1='Dicom';
newname2='Information';
if c>=50
cmd=['rename ',oldname,' ', newname1];
status = system(cmd);
else
cmd=['rename ',oldname,' ', newname2];
status = system(cmd);
end
if status~=0
disp([num2str(a),'修改不成功!']);
end
end
end
disp(['修改文件名完成!用时:',num2str(etime(clock,time)),'秒']);
%%
filepathlist2 = dir(folder_name_all);
for j=3:length(filepathlist2)
a=filepathlist2(j).name;
subfilepathlist = dir(strcat(folder_name_all,'\',a));
b=subfilepathlist(3).name;
if strcmpi('Dicom',num2str(b))
continue;
else
disp([num2str(a),'没有修改成功']);
end
end
disp('验证完成');
diary off