Convertire Tutti I Nomi Delle Cartelle E Dei Files In ASCII Puro
Ci sono molti programmi che non digeriscono caratteri al di fuori dell'ASCII, per questo motivo c'e' il seguente script per convertire tutti i file e le cartelle in maniera ricorsiva con caratteri ASCII (si poteva fare anche lungo la meta'):
#!/usr/bin/rebol
ascii: "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM-_./"
ascii2: charset ascii
funz_ascii: func [ /local lista a ] [
lista: read %.
foreach nomefile lista [
if not (parse to-string nomefile [any ascii2] ) [
a: copy to-string nomefile
foreach char unique trim/with copy a ascii [ replace/all a char "_" ]
funz_testname a
]
]
]
funz_testname: func [name /local b] [
b: copy name
either exists? to-file b [
view layout [
text "The following file already exists:"
text b
text "please rename it:"
newname: field
button "OK" [ unview]
]
funz_testname newname/text
] [ rename nomefile to-file b]
]
;here we go
funz_ascii
Oppure:
#! /usr/bin/perl
use File::Find;
use Text::Unidecode;
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
$_ = unidecode $_ ; # let's unidecode!
rename $old, $_ ;
}, ".";
Io poi consiglio anche il seguente:
#! /usr/bin/perl
use File::Find;
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/ /_/ or return; # don't do anything if you don't have spaces
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/&/e/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/à/a/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/è/e/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/é/e/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/ò/o/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/ù/u/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/ì/i/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/,/_/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/[/_/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/]/_/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/\(/_/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/\)/_/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, "."; # starting directory
finddepth sub { # finddepth so directories are done AFTER their contents
my $old = $_;
tr/'/_/ or return; # don't do anything if you don't have &
-e and return; # don't rename over an existing file!
rename $old, $_ or warn "cannot rename $old to $_: $!";
}, ".";
