Skip to main content
3 of 6
edited body
Stéphane Chazelas
  • 587.9k
  • 96
  • 1.1k
  • 1.7k

This is one way that use internals of Perl tricks:

rename -n 'BEGIN{$main::i = 28} s/_.*/sprintf("_%03d.png", $main::i++)/e' ./*.png 

The trick here is to use the fully-qualified scalar variable $main::i (same as when in package main).

This is a trick to have in the toolchest.

Gilles Quénot
  • 36.8k
  • 7
  • 76
  • 97