Thread Dateien im Ordner durchsuchen und verschieben?! (3 answers)
Opened by yasukatakaya at 2008-06-04 13:16

renee
 2008-06-04 13:55
#110725 #110725
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use warnings;
use Tie::File;
use File::Spec;
use File::Copy qw(move);

my $dir = 'test';
my $out = 'SNNHUB01';

opendir my $dirh, $dir or die $!;
while( my $entry = readdir $dirh ){
    my $path = File::Spec->catfile( $dir, $entry );
    next unless -f $path;

    tie my @lines, 'Tie::File', $path or die $!;
    my $found = grep { /SNNH-UB01-002/ }@lines;
    untie @lines;

    next unless $found;

    my $new = File::Spec->catfile( $out, $entry );
    move $path, $new or die $!;
}
closedir $dirh;


(ungetestet)
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Dateien im Ordner durchsuchen und verschieben?!