#!/usr/bin/perl -w use strict; use MP3::Tag; use File::Find; use File::Copy; use Cwd; print "Pfad angeben wo die MP3's sind!!! [keine Eingabe - Aktuelles Verzeichnis]\n"; # Findet das Aktuelle Verzeichnis my $cwd = getcwd; while () { chomp; $_ = <*.mp3>; find(\&wanted, $_);# findet alles was in dem angegebenen Verzeichnis ist } sub wanted { my ($mp3, $track, $artist,$dir,$info); return unless /mp3$/i; # alles was keine *.mp3 Endung hat wird nicht beachtet if ($mp3=MP3::Tag->new($_)) { print "$_ (Tags: ", join(", ",$mp3->get_tags),")\n"; my @info=$mp3->autoinfo; print "* Song: $info[0]\n"; print "* Track: $info[1]\n"; print "* Artist: $info[2]\n"; print "* Album: $info[3]\n"; print "* Comment: $info[4]\n"; ordner("$info[2] - $info[3]");#übergabe der tags zum ordner erstellen print "\n Ordner wurde bzw ist schon erstellt.\n"; #my $dir = "$cwd/Musik/$info[2] - $info[3]"; #mkdir( $dir ) or die "mkdir( $dir) failed: $!\n";{ #move ($_, "$cwd/$_") or die "Could not move '$_' to '$dir': $!";} my ($oldlocation,$newlocation); $oldlocation = "$cwd"; print "$oldlocation"; $newlocation = "$cwd/$info[2] - $info[3]/$_"; print "\n$newlocation\n"; move($oldlocation, $newlocation) or die "Could not move '$_' zu '$newlocation':$!"; } print "\n Weiter mit Enter!!\n"; } sub ordner { my ($dir) = @_; unless(-e $dir or mkdir $dir) { die "Unable to create $dir\n"; } }