I'm running into an issue where I have a directory of files names:
something1.exr
something2.exr
something3.exr
and I need them named like
projectname.0000001.exr
projectname.0000002.exr
projectname.0000003.exr
I've come up with this:
NAME=image_test_GAM_4778x1806 c=1; for i in *.exr; do mv "$i" `printf $NAME."$c".exr`; let c=c+1; done
and it is able to rename files like:
image_test_GAM_4778x1806.1.exr
image_test_GAM_4778x1806.2.exr
image_test_GAM_4778x1806.3.exr
However, I need the incremented number to have 7-digit padded zeros so I found I can do that with "%07d"
, therefore I assume this code should work:
NAME=image_test_GAM_4778x1806 c=1;
for i in *.exr; do
mv $i $(printf “%s.%07d.exr” “$NAME” “$c”);
let c=c+1;
done
But it doesn't work and complains I'm using mv incorrectly. I know theres something wrong but logically it should make work, I'm trying to pass $NAME and $c to “%s.%07d.exr” respectively.
Can someone point me in the right direction? Any help would be appreciated.
Thank you.