Change image names systematically
Show older comments
I need to change the name of all images in a folder to numerical values like 1.jpg, 2.jpg, ...
I am using this code to do so:
selpath = uigetdir;
imagefiles = dir(fullfile(selpath, '*.jpg'));
% Loop through each
for id = 1:length(imagefiles)
% Get the file name (minus the extension)
[~, f] = fileparts(imagefiles(id).name);
movefile(f,num2str(id));
end
I get this error:
Error using movefile
No matching files were found.
Error in Rename_images (line 14)
movefile(f,num2str(id));
Any idea of why? and how can I fix this?
Accepted Answer
More Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!