Using Date within Rename command

Hello evrybody
try this

rename -n '@D=/^(\d*)-(\d*)-\d*_(.*)\..*/;use POSIX qw(strftime);
$d=strftime "%B_%Y",0,0,0,0,@D[1],@D[0]-1900;s/^[^.]*/@D[2]_$d/' *pdf

For me, this is purely sports interest, it is easier to use a loop in shell

Slightly tweaked

rename -n '@D=/^(\d*)-(\d*)-\d*_([^.]*)/;use POSIX qw(strftime);
$d=strftime "%B_", 0,0,0,0,@D[1],0;s/[^.]*/@D[2]_$d@D[0]/' *pdf

Don't forget about localization LC_ALL=C prename...

2 Likes