-
Notifications
You must be signed in to change notification settings - Fork 0
/
changeExtensionByEval.m
83 lines (72 loc) · 2.32 KB
/
changeExtensionByEval.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% inputDir = 'D:\temp5\20171010\1\1';
function changeExtensionByEval(inputDir, varargin)
global cfg
if (nargin == 1)
nameStr = 'imgR';
dlt = 0;
elseif (nargin == 2)
nameStr = varargin{1};
dlt = 0;
elseif (nargin == 3)
nameStr = varargin{1};
dlt = varargin{2};
else
error('Too many input arguments');
end
dirInfo = dir(fullfile(inputDir,'*.png'));
if length(dirInfo) == 0
dirInfo = dir(fullfile(inputDir,'*.bmp'));
end
if length(dirInfo) == 0
dirInfo = dir(fullfile(inputDir,'*.jpg'));
end
if 0
dircell=struct2cell(dirInfo);
if 0
aaAa = dircell(2,:)';
sss = datetime(aaAa,'Format','dd-MMM-y HH:mm:ss');
[B,I] = sort(sss);
else
[~, ind1] = sort([dirInfo(1:length(dirInfo)).datenum], 'ascend');
I = ind1;
end
tempInfo = cell(length(I),1);
for fg = 1:length(I)
tempInfo{fg,1} = dirInfo(I(fg)).name;
end
for fgg = 1:length(I)
dirInfo(fgg).name = tempInfo{fgg};
end
end
frameNum = length(dirInfo); 1/2; %/2;
workDir = pwd;
cd (inputDir);
ct = 5725;
for i = 1: frameNum %length(dirInfo)
if 0
img = imread(fullfile(inputDir,dirInfo(i).name));
% name = str2double(dirInfo(i).name(5:end-4));
% name = name.*100; name = round(name);
% name = name*10000000 + 1000000000000000000;
if 0
imwrite(img,strcat(inputDir,'\',sprintf('%19.0f',name),'.png'));
else
% imwrite(img, sprintf(strcat(nameStr, '_%04d.png'), i));
imwrite(img, sprintf('a%06d.png', i-1));
end
elseif 1
eval(['!rename' 32 dirInfo(i).name 32 sprintf(strcat(nameStr, '_%04d.png'), i+dlt)]);
elseif 0
eval(['!rename' 32 dirInfo(i).name 32 sprintf('a%06d.png', i-1)]);
else
eval(['!rename' 32 dirInfo(i).name 32 sprintf('%06d.png', ct)]);
end
ct = ct+1;
% eval(['!rename' 32 dirInfo(i).name 32 sprintf('t1_%04d.png', i)]);
% eval(['!rename' 32 dirInfo(i).name 32 sprintf(strcat(nameStr, '_%04d.png'), i)]);
% % % % % % eval(['!rename' 32 dirInfo(i).name 32 sprintf( '%06d.png', i-1)])0;
% eval(['!rename' 32 dirInfo(i + frameNum).name 32 sprintf('imgR_%04d.png', i)]);
% eval(['!rename' 32 dirInfo(i).name 32 sprintf('rectR_%04d.png', i)]);
end
cd (workDir)
end