====== Utilities ====== ===== TV episode renaming script ===== This perl script, or win32 binary offers a comprehensive solution for automatically renaming files belonging to a TV series. http://www.robmeerman.co.uk/coding/file_renamer ===== MP3 Renamer and Organiser script ===== http://aranger.sourceforge.net/ ===== Regex file renamer ===== renrx.pl from http://www.perlmonks.org/?node_id=311703 use strict; &renameFiles( &getArgs() ); - ------------------- SUBROUTINES ------------------- sub printUsage { print < perl renrx.pl ["" []] Where, * the regular expression to use * is 0 to disable preview; anything otherwise EOF } sub getArgs { my ($reg, $prompt) = ("", 1); if ( @ARGV == 2 ) { ($reg, $prompt) = @ARGV; unless ( $prompt == 0 ) { $prompt = 1; } } elsif ( @ARGV == 1 ) { ($reg) = @ARGV; } else { # unexpected number of args &printUsage(); exit; } return ($reg, $prompt); } sub renameFiles { my ($reg, $prompt) = @_; my @files = <*>; foreach (@files) { my $before = $_; eval $reg; my $after = $_; if ( $before eq $after ) { next; } # nothing to do if ( $prompt ) { print "$before => $after\n"; print "Rename? [[Yes|No|Always|Cancel]] "; chomp (my $resp = ); if ( $resp =~ m/^y/i ) { # do nothing } elsif ( $resp =~ m/^n/i ) { next; } elsif ( $resp =~ m/^a/i ) { $prompt = 0; } elsif ( $resp =~ m/^c/i ) { exit; } else { print "Invalid choice.\n"; exit; } } # if prompt rename( $before, $after ); } }