Rename files in the folder

조회 수: 2 (최근 30일)
Turbulence Analysis
Turbulence Analysis 2020년 9월 21일
댓글: Turbulence Analysis 2020년 9월 21일
Hi,
I have files like B00001.im7 ..... B10000.im7 inside the particular folder, Here, I intend to replace 'B' by 'P'
for e.x. B00001.im7 to P00001.im7. Please suggest the way to do this..

채택된 답변

Mario Malic
Mario Malic 2020년 9월 21일
편집: Mario Malic 2020년 9월 21일
movefile 'B00001.im7' 'P00001.im7' % or supply full path to the files
  댓글 수: 5
Mario Malic
Mario Malic 2020년 9월 21일
편집: Mario Malic 2020년 9월 21일
This should do it.
Dir_files = dir('*.im7');
List_Files = {Dir_files.name}'; % Cell (length(Dir_files, 1) that contain filenames
List_Files(:,2) = List_Files(:,1); % Copying cells to second column
for ii = 1:length(List_Files)
List_Files{ii,2}(1) = 'P'; % Change first character in 2nd column of each file
movefile (List_Files{ii,1}, List_Files{ii,2});
end
Turbulence Analysis
Turbulence Analysis 2020년 9월 21일
Thanks a lot. It worked perfectly...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by