On Mon, Oct 10, 2005 at 03:45:16PM +0200, Daniele Ludovici wrote: [...] > io uso questo script scritto da me, non e' la perfezione ma direi che e' > passabile.
mi sono permesso di estendere il tuo script. Ora accetta espressioni da usare con glob per rinominare un elenco di files (salta le directories). [...] > # Toglie tutto il resto > s/[^\w .-]//sg; questo l'ho tolto perche fa dei danni in realta'... --8<-- CUT HERE --8<-- #!/usr/bin/perl -w use strict; use File::Copy; use File::Glob; use Getopt::Long; use POSIX qw(:errno_h); my $interactive = 0; my $debug = 0; my $verbose = 0; my $lowercase = 0; my $orig_filename; my $answ; if (!GetOptions ("interactive" => \$interactive, "debug" => \$debug, "lowercase" => \$lowercase, "verbose" => \$verbose) || @ARGV != 1) { print <<EOHELP; usage: $0 [-i/--interactive] [-d/--debug] [-v/--verbose] [-l/--lowercase] EXPR EOHELP exit EINVAL; } foreach (<$ARGV[0]>) { next unless -f; $orig_filename = $_; # converte tutte le accentate minuscole tr/[\xe0\xe1\xe8\xe9\xec\xed\xf2\xf3\xf9\xfa/aaeeiioouu/; s/([\x80-\xff])/ord($1)/eg; # smanazza i caratteri estesi #mette tutto a lowercase (a me piace cosi') tr/A-Z/a-z/ if $lowercase; # Converte spazi, elimina ridondanze di distanziamento s/[\s_]+/_/g; # Elimina spuri iniziali e finali s/^[_-]+//; s/[_-]+$//; s/_-_/-/; print "$orig_filename -> $_" if $debug; next if $orig_filename eq $_; if (!length($_)) { print "ma che razza di nome e' '$_' per un file??\n"; next; }; if ($interactive) { print "Vuoi rinonminare '$orig_filename' in '$_'? [y/N] "; chomp($answ = <STDIN>); next unless ($answ =~ m/^[yY]$/); } move($orig_filename, $_); print "Rinominato $orig_filename in $_ \n" if $verbose; } exit 0; --8<-- CUT HERE --8<-- -- mattia :wq! -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]