Peter Stock: erster Buchstabe groß

Beitrag lesen

Hallo,

danke Ihr beiden!
Ich habe mich schon für total doof gehalten, aber so einfach war es ja dann doch nicht.
Aus der Kombination Eurer Antworten, habe ist das Rätsel doch noch gelöst!
Das angesprochene Problem, daß bei Zahlen und "_" auftritt, habe ich "elegant" gelöst, indem ich die Teile erst mit Pipes einklammere und diese später wieder entferne.

Zum Dank, hier das Ergebnis meiner "Arbeit", vielleicht kann man es ja mal gebrauchen?! :-)

#!/usr/bin/perl

use  MP3::Info;
use locale;

system ("find -iname \*.mp3 > /tmp/mp3.rename");

open (in,"/tmp/mp3.rename");
while ($line = <in>)
        {
                $line =~ s/\n//;
                $mp3_info = get_mp3tag ($line);
                $artist = $mp3_info->{ARTIST};
                $album  = $mp3_info->{ALBUM};
                $title  = $mp3_info->{TITLE};
                $track  = $mp3_info->{TRACKNUM};

$artist =~ s/_/ /g;
                $album  =~ s/_/ /g;
                $title  =~ s/_/ /g;

$artist =~ s///-/g;
                $album  =~ s///-/g;
                $title  =~ s///-/g;

$artist =~ s/([0-9])/|$1|/g;
                $album  =~ s/([0-9])/|$1|/g;
                $title  =~ s/([0-9])/|$1|/g;

$artist =~ s/-/|-|/g;
                $album  =~ s/-/|-|/g;
                $title  =~ s/-/|-|/g;

$artist = lc($artist);
                $album  = lc($album);
                $title  = lc($title);

$artist =~ s/\b([a-zA-ZäöüÄÖÜß])/\u$1/g;
                $album  =~ s/\b([a-zA-ZäöüÄÖÜß])/\u$1/g;
                $title  =~ s/\b([a-zA-ZäöüÄÖÜß])/\u$1/g;

$artist =~ s/ /_/g;
                $album  =~ s/ /_/g;
                $title  =~ s/ /_/g;

$artist =~ s/|//g;
                $album  =~ s/|//g;
                $title  =~ s/|//g;

if (length($track) < 2)
                        {
                                $track = "0".$track;
                        }

$artist =~ tr/-,.öäüßÖÄÜ&()A-Za-z_0-9/_/c;
                $album  =~ tr/-,.öäüßÖÄÜ&()A-Za-z_0-9/_/c;
                $title  =~ tr/-,.öäüßÖÄÜ&()A-Za-z_0-9/_/c;
                $track  =~ tr/0-9//c;

if (length($track) != 2)
                        {
                                $track = '';
                        }

$artist =~ s/__/_/g;
                $album  =~ s/__/_/g;
                $title  =~ s/__/_/g;

if ($artist and $album and $title and $track)
                        {
                                system ("mkdir -p "/home2/neu/$artist/$album"");
                                system ("cp "$line" "/home2/neu/$artist/$album/$track-$title.mp3"");
                        }
        }
close in;

Peter
, der eigentlich Paul heißt... hatte mich wegen der Frage sooo geschämt.