I have hundred of id file with format like this
106527-Sup, Perman .jpg 106528-Iron, man .jpg 106529-Bat, man .jpg 106530-Spider, man .jpg
I need to rename them to
106527.jpg 106528.jpg 106529.jpg 106530.jpg
use perl-based rename:
rename 's/^(\d+).*jpg$/$1\.jpg/' *.jpgrename 's/^(\d+).*$/$1.JPG/' *
^matches the position at the beginning of the input\d+matches one or more digit.*matches everything in between$matches the position at the end of the input
The first group ($1) contains the digits you want to replace with.