I am a beginner at shell scripting. I have 4 images:
1.png, 2.png, 3.png, 4.png
How do I rename these images to:
img1.png, img2.png, img3.png, img4
I am a beginner at shell scripting. I have 4 images:
1.png, 2.png, 3.png, 4.png
How do I rename these images to:
img1.png, img2.png, img3.png, img4
Use this as a script with your file names as input. It is untested, but should give you a clue
#! /bin/bash
for file in "$@"; do
mv "$file" "img${file}"
done
Have a look for the rename command, you can do something like
rename s/^/img/g *png
This substitutes (s/
) the beginning of a file name (noted as the ^
) with img
for all files ending in png (*png
)
.if you don't have it, you can get the command from here http://stackoverflow.org/wiki/Rename.pl
for instance