200 개의 JPEG 이미지가있는 디렉토리가 있습니다. 내가 원하는 것은이 모든 이미지의 이름을 바꾸는 것입니다. 그렇다면 어떻게 내 모든 이미지의 이름을 동시에 바꿀 수 있습니까? 예를 들어 첫 번째 이미지의 이름을 "hello1", 두 번째 "hello2", 세 번째 이미지의 이름은 "hello3"> 200의 경우 "hello200"로 변경합니다.디렉토리의 모든 이미지의 이름을 바꾸는 방법
아래 코드는 다음과 같습니다.
maximagesperdir = inf;
directory='imagess';
dnames = {directory};
fprintf('Reading images...');
cI = cell(1,1);
c{1} = dir(dnames{1});
if length(c{1})>0,
if c{1}(1).name == '.',
c{1} = c{1}(4:end);
end
end
if length(c{1})>maximagesperdir,
c{1} = c{1}(1:maximagesperdir);
end
cI{1} = cell(length(c{1}),1);
for j = 1:length(c{1}),
cI{1}{j} = double(imread([dnames{1} '/' c{1}(j).name]))./255;
end
fprintf('done.\n');
시도 http://www.mathworks.com/matlabcentral/answers/1760-how-to-rename-a-bunch-of-files-in-a-folder – Leo
항상있다. [자신에게 두 가지 문제를 부여하는] 옵션 (http://www.mathworks.co.uk/help/matlab/ref/regexprep.html)도 있습니다. – Notlikethat