Ritielko Ritielko - 1 year ago 53
Perl Question

Getting random number sequence on a filename using rename on Linux

So I'm trying to mass rename folder full of JPG-files using the 'rename'-tool

End result should be looking something like this

745I-(five random numbers)

I need something that gives me those five random numbers, the rest works fine

rename -n 's/\w+/745I\- [stuff] /' *.jpg

Most things just, like those two, act as strings instead of code or give gibberish

$(( ( RANDOM % 1000) + 1000))

Answer Source

Your version of rename uses a Perl substitution, to execute code in the replacement, you need /e:

s/\w+/10000 + int rand 90000/e