[LUGOS] empetri jeba
Gregor Fajdiga
Gregor.Fajdiga at select-tech.si
Mon Jun 30 14:44:05 CEST 2003
jest nucam nekej tazga.
#!/usr/bin/perl
use strict;
my @list;
my @type;
my $subst;
my $nosubst;
my $count = 0;
# folder you want the script to start in
my $startdir = "$ARGV[0]";
genfilelist($startdir);
sub genfilelist() {
my ($workdir) = @_;
opendir FILELIST, $workdir;
my @filelist = readdir FILELIST;
closedir FILELIST;
foreach (@filelist) {
if ($_ eq "." || $_ eq "..") {
goto END;
}
if (-d "$workdir/$_") {
push @list, "$workdir/$_";
push @type, "dir";
$nosubst = $_;
$subst = $_;
$subst =~ s/\s/_/g;
$subst =~ s/[&]/and/g;
$subst =~ s/[^\w_-]//g;
if ($subst ne $nosubst) {
$nosubst =~ s/\"/\\\"/g;
system "mv -v \"$workdir/$nosubst\" $workdir/$subst";
}
$count++;
genfilelist("$workdir/$subst");
} else {
push @list, "$workdir/$_";
push @type, "file";
$nosubst = $_;
$subst = $_;
$subst =~ s/\s/_/g;
$subst =~ s/[&]/and/g;
$subst =~ s/[[.]^\w_-]//g;
if ($subst ne $nosubst) {
$nosubst =~ s/\"/\\\"/g;
system "mv -v \$\"$workdir/$nosubst\" $workdir/$subst";
}
$count++;
}
END:
}
}
pozdrav,
gregor.
On Mon, 30 Jun 2003 11:38:56 +0200
Uro¹ Golja <goljau at comcom.si> wrote:
> Pozdravljeni,
>
> na debian ki¹ti se mi nabira huronska kolièina empetrijev So bolj ali
> manj sortirani po izvajalcih in albumih, pri èemer je vsak album v
> svojem direktoriju. Nekatere datoteke imajo unix-friendly imena (=brez
> presledkov in ostalih moteèih znakov), druge pa ne. Rad bi jih spravil
> na skupni imenovalec.
>
> Programu abcde sem ukradel funkcijo mungefilename(), ki se glasi takole:
> sed s,:,\ -,g | tr \ / __ | tr -d \'\"\?\[:cntrl:\]
>
> Sedu vr¾em nekaj na stdin, na stdout dobim ¾eljeno obliko neèesa. Sedaj
> bi pa rad napisal bash skripto, ki bi se sprehodila po vseh datotekah in
> poddirektorijih na podani poti in preimenovala vsako reè, ki jo najde.
> ®al sem v bashu gol in bos. Nekaj sem èaral s find in xargs, pa mi ni
> ratalo. Se komu ljubi napisati domaèo nalogo namesto mene?
>
> LP,
> Uro¹
>
>
More information about the lugos-list
mailing list