New answers tagged rename
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 ...
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:
...
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 ...
Top 50 recent answers are included
Related Tags
rename × 1231bash × 289
files × 237
shell-script × 182
filenames × 158
shell × 132
linux × 129
find × 112
mv × 106
regular-expression × 72
command-line × 71
scripting × 69
directory × 65
sed × 51
file-copy × 31
perl × 30
macos × 30
cp × 29
recursive × 28
date × 23
ubuntu × 22
awk × 22
zsh × 21
terminal × 19
wildcards × 19