Skip to main content

New answers tagged

0 votes

how to set an initial value when batch renaming to sequential numbering?

This is one way that use Perl main internals, without the need to use our global variable: rename -n 'BEGIN{$main::i = 28} s/_.*/sprintf("_%03d.png", $main::i++)/e' ./*.png The solution ...
Gilles Quénot's user avatar
4 votes

how to set an initial value when batch renaming to sequential numbering?

A simple approach here is to do: our $i //= 28; That is still declare it as a package global variable to work around strict but only assign 28 if not already defined. Alternatively, with zsh's zmv: ...
Stéphane Chazelas's user avatar
4 votes
Accepted

how to set an initial value when batch renaming to sequential numbering?

As you've already discovered, putting our $i = 28; in the main script doesn't work because it resets $i to 28 for every filename - rename executes every statement in the main script once for every ...
cas's user avatar
  • 83.9k

Top 50 recent answers are included