Any one of the following commands will do your job
c=0 rename 's/\./sprintf(".%d.",++$ENV{c})/e' *.phy
rename 's/\./".".++$a."."/e' *.phy
rename '$a++; s/\./.$a./e' *.phy
n=1;for f in *.phy; do mv "$f" "${f%.*}.$n.${f##*.}"; n=$((n+1)); done
Either
It executes the perl s///
expression, and performs the rename from the
original to the replaced string. In the replacement string I use
sprintf
to format the name, where I use the environment variable c
as
the counter
$ touch Ortho234.phy Ortho671.phy Ortho880.phy
$ ls *.phy -1
Ortho234.phy
Ortho671.phy
Ortho880.phy
$ c=0 rename 's/\./sprintf(".%d.",++$ENV{c})/e' *.phy
$ ls *.phy -1
Ortho234.1.phy
Ortho671.2.phy
Ortho880.3.phy
OR
$ touch Ortho234.phy Ortho671.phy Ortho880.phy
$ ls *.phy -1
Ortho234.phy
Ortho671.phy
Ortho880.phy
$ n=1;for f in *.phy; do mv "$f" "${f%.*}.$n.${f##*.}"; n=$((n+1)); done
$ ls *.phy -1
Ortho234.1.phy
Ortho671.2.phy
Ortho880.3.phy
OR
$ touch Ortho234.phy Ortho671.phy Ortho880.phy
$ ls *.phy -1
Ortho234.phy
Ortho671.phy
Ortho880.phy
$ rename 's/\./".".++$a."."/e' *.phy
$ ls *.phy -1
Ortho234.1.phy
Ortho671.2.phy
Ortho880.3.phy
OR
$ touch Ortho234.phy Ortho671.phy Ortho880.phy
$ ls *.phy -1
Ortho234.phy
Ortho671.phy
Ortho880.phy
$ rename '$a++; s/\./.$a./e' *.phy
$ ls *.phy -1
Ortho234.1.phy
Ortho671.2.phy
Ortho880.3.phy