I have a directory which contains image files with names like
image1.jpg
image2.jpg
image3.jpg
...
Unfortunately, the image names must be zero based, so image1.jpg
should be image0.jpg
, image2.jpg
should be image1.jpg
and so on.
I can write a script to generate mv commands like these, put them in a shell script, and then execute them -
mv image1.jpg image0.jpg
mv image2.jpg image1.jpg
mv image3.jpg image2.jpg
...
But I suppose there is a neater way to do it in Unix. So what is it?
for i in $(seq 0 100); do mv image$[i+1].jpg image$i.jpg; done
)imageN.jpg
toimage0.jpg
and you are done.