forked from sattarab/image-quality-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangeName.m
24 lines (22 loc) · 800 Bytes
/
changeName.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
%script for reading the file names and converting it to the appropraite
%name
%Directory of the files
function changeName(location)
% example location = 'C:\Users\abdullah\Desktop\design project\DesignProject\Image Set\';
% Retrieve the name of the files only
names = dir(location);
names = {names(~[names.isdir]).name};
% Calculate the length of each name and the max length
len = cellfun('length',names);
mLen = max(len);
% Exclude from renaming the files long as the max
idx = len < mLen;
len = len(idx);
names = names(idx);
% Rename in a LOOP
for n = 1:numel(names)
oldname = [location names{n}];
newname = strcat('image', int2str(n), 'Orig.jpg');
dos(['rename "' oldname '" "' newname '"']); % (1)
end
end