Experts, I am trying to rename some images with the following code. The new names should be '1.jpg', '2.jpg' etc. However, I get ' 1.jpg', ' 2.jpg' etc. Note there is a space before each digit. What is the issue with my code?
a ='C:\Users\Faraz\Desktop\IBHS\Flame height\Frames\';A =dir( fullfile(a, '*.jpg') );fileNames = { A.name };for iFile = 1 : numel( A )newName = fullfile(a, sprintf( '%2d.jpg', iFile ) );movefile( fullfile(a, fileNames{ iFile }), newName );end
Best Answer