in reply to Re^2: Removing characters in a file name
in thread Removing characters in a file name

I like the idea from choroba, but I would perhaps do it a bit differently. The OP doesn't specify what to do if the rename cannot happen. I would just "die" in that case with an error message. I would only process .mp4 files that match the pattern, but again that is up to the OP to decide how to handle an .mp4 file that doesn't match the pattern.
use strict; use warnings; foreach my $file ('Jane Doe & John Doe - 124 - How to Invest.mp4', 'Jane Smith & John Smith - 100 - Stocks.mp4', 'Jane Black & John Black - 90 - Bonds.mp4', 'Jane Black & John Black - 120 - Bonds2Invest.mp4', 'Jane Black & John Black - 123 - Bonds 2 Invest.mp4' +, ) { if ( (my $num) = $file =~ / (\d+) - [\w ]+.mp4$/ ) { #rename $file, "[Books] $num.mp4" or die "Cannot rename $file to + $num.mp4 - probable cause: duplicate number: $!"; print "$num.mp4\n"; } } __END__ 124.mp4 100.mp4 90.mp4 120.mp4 123.mp4