How to add a suffix to all files in the current directory in bash?
Here is what I've tried, but it keeps adding an extra .png
to the filename.
for file in *.png; do mv "$file" "${file}_3.6.14.png"; done
locate command syntax: Similarly, you can follow the syntax of locate command for finding all files with any specific extension such as “. txt.”
Just say echo "" >> file . This will append a new line at the end of file .
for file in *.png; do mv "$file" "${file%.png}_3.6.14.png" done
${file%.png}
expands to ${file}
with the .png
suffix removed.
You could do this through rename command,
rename 's/\.png/_3.6.14.png/' *.png
Through bash,
for i in *.png; do mv "$i" "${i%.*}_3.6.14.png"; done
It replaces .png
in all the .png
files with _3.6.14.png
.
${i%.*}
Anything after last dot would be cutdown. So .png
part would be cutoff from the filename.mv $i ${i%.*}_3.6.14.png
Rename original .png files with the filename+_3.6.14.png.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With