in reply to Remove (nearly) duplicate files recursively

my $orig = $File::Find::name; $orig =~ s/ 1\.mp3/.mp3/; if (-e $orig){ print "Counterpart exists\n"; }

Update: fixed substitution, linuxer++

Replies are listed 'Best First'.
Re^2: Remove (nearly) duplicate files recursively
by linuxer (Curate) on May 19, 2008 at 09:48 UTC

    small correction in the substitution

    $orig =~ s/ 1\.mp3/.mp3/;
Re^2: Remove (nearly) duplicate files recursively
by wrinkles (Pilgrim) on May 19, 2008 at 10:22 UTC
    Thanks moritz, here's the updated code:
    #!/usr/bin/perl -w use strict; use File::Find; find(\&process, '/Users/Shared/Music'); sub process { my $song = $File::Find::name; my $orig = $song; $orig =~ s/ 1\.mp3/.mp3/; if ( (m/[\d\D]*\s+1.mp3$/) && (-e $orig) ){ rename "$song", "/Users/wrinkles/dupes/$_" or die $!; print "$song removed. \n"; } }