I originally had a set of images of the form image_001.jpg, image_002.jpg, ...
I went through them and removed several. Now I\'d like to rename the leftover files ba
A simple loop (test with echo
, execute with mv
):
I=1
for F in *; do
echo "$F" `printf image_%03d.jpg $I`
#mv "$F" `printf image_%03d.jpg $I` 2>/dev/null || true
I=$((I + 1))
done
(I added 2>/dev/null || true
to suppress warnings about identical source and target files. If this is not to your liking, go with Matthew Flaschen's answer.)