# Using Date within Rename command

**URL:** <https://community.unix.com/t/using-date-within-rename-command/379728>\
**Category:** Shell Programming and Scripting\
**Created:** [August 25, 2020, 3:45pm UTC](https://community.unix.com/t/using-date-within-rename-command/379728 "2020-08-25T15:45:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![nezabudka](https://community.unix.com/letter_avatar/nezabudka/32/5_5575768a8748004e209b776fc1b2916d.png) [@nezabudka](https://community.unix.com/u/nezabudka)\
**Post date:** [August 25, 2020, 10:25pm UTC](https://community.unix.com/t/using-date-within-rename-command/379728/6 "2020-08-25T22:25:48Z")

</div>

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...`

---

_[View the full topic](https://community.unix.com/t/using-date-within-rename-command/379728)._
