Thread Funktionen für Dateihandling gesucht (21 answers)
Opened by kami at 2010-03-28 13:06

Gast wer
 2010-03-28 22:26
#135410 #135410
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
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w

use strict;
use warnings;
use Getopt::Long;

use File::Copy;
use File::Spec;
use File::Glob ':glob';

my ($source_path, $txt_check, $verzeichnis, $dest_path,$file); 
my %options = ();
GetOptions(\%options, 'txt=s');

my $downloaddir='/home/kami/download';
my $finaldir='/home/kami/final';

$verzeichnis=File::Spec->join($downloaddir, $options{'txt'});

# TXT Dateien suchen und kopieren

$txt_check=File::Spec->join($verzeichnis, '*.txt');
print $txt_check."\n";
if(bsd_glob($txt_check)){
  print "1\n"; 
  for $source_path (bsd_glob($txt_check)){
    print "SOURCE $source_path\n";
    if(-f $source_path){   
      (undef,undef,$file) = File::Spec->splitpath( $source_path );
           
      $dest_path=File::Spec->join($finaldir, $file);
      print "DEST $dest_path\n";
      copy($source_path,$dest_path) or die("ERROR copy($source_path,$dest_path) $!\n");
    }
  }
}

Last edited: 2010-03-28 22:51:01 +0200 (CEST)

View full thread Funktionen für Dateihandling gesucht