How to change the name of the images from frame1.jpg , frame2. jpg to image1.jpg etc etc

1 次查看(过去 30 天)
Hi,
I would like to change the name of 100 images from frame...jpg to image 1.jpg , image2.jpg etc etc.
can you guys help?
Regards,
M Choudhry.

采纳的回答

Ameer Hamza
Ameer Hamza 2020-9-29
编辑:Ameer Hamza 2020-9-30
Something like this
files = dir('*.jpg');
for i = 1:numel(files)
old_name = files(i).name;
new_name = strrep(old_name, 'frame', 'image');
movefile(old_name, new_name)
end
  2 个评论
muhammad choudhry
muhammad choudhry 2020-9-30
Hi,
what am I doing wrong here?
Code:
files = dir('*.jpg ');
for i = 1:numel(files )
frame = files(i).name ;
image = strrep(frame , ' ', '');
movefile(frame, image )
end
Error:
Error using movefile
Cannot copy or move a file or directory onto itself.
Error in frametoimage (line 9)
movefile(frame, image )
Ameer Hamza
Ameer Hamza 2020-9-30
Sorry, there was a mistake. Check the updated code. Also, does the old file names should start with the frame, all lower case.

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2020-9-29

Community Treasure Hunt

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

Start Hunting!

Translated by