9 entries, 1 page |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use strict;
use warnings;
use File::Copy;
use Cwd;
my $home_dir = getcwd;
$home_dir = "$home_dir/files";
opendir DIR, $home_dir;
my @org_files = grep "$home_dir/$_",readdir DIR;
closedir DIR;
for my $new_files(@org_files)
{
$new_files =~ s/2005/2006/g;
print $new_files,"\n";
}
1
2
3
$old = $new_files;
$new_files =~ s/2005/2006/g;
copy( $old, $new_files ) or die "Copy failed: $!";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use File::Copy;
my home_dir = getcwd . "/files";
opendir (my $DIR, $home_dir) or die "Error: couldn't open dir $home_dir: $!\n";
FILE:
while (my $file = "$home_dir/" . readdir($DIR) ) {
# ueberspringe verzeichnisse, links, ... nur wirkliche dateien nicht
next FILE unless -f $file;
# ersetze das erste vorkommen von 2005 durch 2006
(my $newFile = $oldFile) =~ s/2005/2006/;
# versuche zu kopieren
copy($oldFile, $newFile) or
die "Error: couldn't copy '$oldFile' => '$newFile': $!\n";
} # while
closedir $DIR;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings;
use File::Copy;
use Cwd;
my $home_dir = getcwd;
$home_dir = "$home_dir/tangosimu";
opendir(DIR,$home_dir) or die $!;
while (my $filename = readdir DIR)
{
my $new_files = $home_dir . '/' . $filename;
next unless -f $new_files;
my $old = $new_files;
$new_files =~ s/2005/2006/g;
if ($old eq $new_files) {
}
else {
copy("$old", "$new_files") or die "Copy failed: $!";
}
}
closedir DIR;
1
2
3
4
5
if ($old eq $new_files) {
}
else {
copy("$old", "$new_files") or die "Copy failed: $!";
}
9 entries, 1 page |