Thread dircopy legt 2 Verzeichnisse an (24 answers)
Opened by bob.george at 2016-04-24 15:25

bob.george
 2016-04-24 15:25
#184587 #184587
User since
2011-09-02
104 Artikel
BenutzerIn
[default_avatar]
Hallo liebe community,
ich habe hier folgenden Code:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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.");
}

Inhalte der Variablen:
$path = '\\SERVER\Öffentlich\quelle\Bilder/Gardasee/20090615'
$path_ziel = 'C:\test\ziel\Bilder\Gardasee/090615'
$pfad_ort = 'C:\test\ziel\Bilder\Gardasee'

Der Code soll ggfs. $path_ziel löschen und dann den dircopy-Befehl ausführen. Der dircopy wird auch sauber ausgeführt, nur legt er 2 Verzeichnisse an. Einmal $path_ziel_neu und dann noch das ehemals gelöschte $path_ziel. In der Quelle existiert jedoch nur das Verzeichnis $datum. Habt Ihr eine Idee? Ich verzweifel langsam.
Last edited: 2016-04-26 17:09:42 +0200 (CEST)

View full thread dircopy legt 2 Verzeichnisse an