I have 1000 jpg files with file names:1_nb_1_0.0164032559841871, 1_nb_1_20.0611820686609, and I want to rename those 1000 with new names by incrementing two characters such as rename to this name:1_nb_1_20.0611820686609 but incrementing 20 for the new other images.
datafiles = dir('*.jpeg');
for i = 1:length(datafiles)
fileOut = strrep(datafiles(i).name, '1_nb_1_0.0164032559841871.jpeg', '.jpeg');
movefile(datafiles(i).name, fileOut);
end
`
From what I can understand, what you are trying to do in:
is replace'1_nb_1_0.0164032559841871.jpeg' with the new name? And the new names are from 20 to the end in jumps of 20? If that is the case you can just put it like this:
And this creates the names 20.jpg,40.jpg,60.jpg... If what you want is just do this within another name like the one you already have it can also be done like this:
and then you will get 1_nb_1_20.0611820686609.jpg,1_nb_1_40.0611820686609.jpg,... I am not sure if this is what you wanted. If you wanna start with 0 instead of 20 you can change it with num2str(20*(i-1)) or starting with 40 with num2str(20*(i+1))