use File::Copy::Recursive qw(dircopy); use File::Path qw(rmtree); sub remove_and_copy{ my ( $path_ziel, $path, $pfad_ort) = @ARG; $path =~ /(\Q$verzeichnisname_quelle\E)([\\\/]+)(.+)([\\\/]+)(.+)/; my $datum= $5; if ($path_ziel ne ''){ rmtree($path_ziel) || Fehlerausgang("Konnte Verzeichnis \"$path_ziel\" nicht löschen: $!"); print_konsole_und_log("\nVerzeichnis $path_ziel gelöscht."); } my $path_ziel_neu = $pfad_ort."\\".$datum; mkdir($path_ziel_neu); $path =~ s/\//\\/g; dircopy($path, $path_ziel_neu) || Fehlerausgang("Konnte Verzeichnis \"$path\" nicht nach \"$path_ziel_neu\" kopieren: $!"); print_konsole_und_log("Verzeichnis \"$path\" nach \"$path_ziel_neu\" kopiert."); }