renaming the image files

3 Ansichten (letzte 30 Tage)
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM am 10 Jun. 2014
Beantwortet: Image Analyst am 10 Jun. 2014
I have more than hundred pictures and i want to rename them..
old name : 1_new, 2_new...... new name : tour1_pictures, tour2_pictures,.......

Akzeptierte Antwort

ES
ES am 10 Jun. 2014
1. Get the Files in the directory... ([~,ListofImages]=dos('dir /b /s te_*.jpg');)
2. Get the Number from it..(1, 2, etc) (RegExFileName = '[0-9]+_new'; [~,StartIdx]=regexpi(FileName, RegExFileName , 'match');)
3. Format New Name, (NewFileName=['tour',num2str(index),'_pictures'])
4 do a movefile to rename.. movefile(SourceFileName, NewFileName);
  3 Kommentare
RAMESH MUNIRATHINAM
RAMESH MUNIRATHINAM am 10 Jun. 2014
can i get some example program regarding it. pls
ES
ES am 10 Jun. 2014
%%IMPORTANT: Not tested as I dont have MATLAB in my PC now!
[~,ListofImages]=dos('dir /b /s *.jpg');
FileIndexes=[0,strfind(ListofModels,'.jpg')+4];
RegExFileName = '[0-9]+_new';
for loop1 = 1:length(FileIndexes)-1;
FileFullName_Old=ListofModels(FileIndexes(loop1)+1:FileIndexes(loop1+1)-1);
[FilePath,FileName,~]=fileparts(FileFullName_Old);
[~,StartIdx]=regexpi(FileName, RegExFileName , 'match');
FileIndx = FileName(1:end-4);
FileIndx = str2num(FileIndx);
NewFileName = ['tour',num2str(FileIndx),'_pictures'];
FileFullName_New=fullfile(FilePath,NewFileName);
movefile(FileFullName_Old,FileFullName_New);
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 10 Jun. 2014

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by