sprintf extra space character!
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Search Path en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!