in reply to Re^2: Removing characters in a file name
in thread Removing characters in a file name
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
|
|---|