Issue
I have many pictures in a folder /home/pictures in linux.
image1.jpg
image2.jpg
image4.png
image3.jpg
....
How I can add a suffix to the files in the command line with a .jpg extension to get this result:
ext_image1.jpg
ext_image2.jpg
image4.png
ext_image3.jpg
Solution
Do you mean add a suffix to the file name or a prefix to the file name, if you want to add a prefix(according to your example):
you could implement it with find
in bash
or zsh
:
cd /home/pictures
find * -name '*.jpg' -exec mv {,ext_}{} \;
With Brace Expansion:
mv {,ext_}image1.jpg
# expands to
mv image1.jpg ext_image1.jpg
This works for me.
Answered By - ramsay Answer Checked By - Senaida (WPSolving Volunteer)