# rename random file names to incrementing numbers with prefix (new_name) rename 'our $i; s/^[^.]+/sprintf "new_name-%02d", $i++/e' *.jpg # output: new_name-00.jpg new_name-01.jpg etc