#!/usr/bin/perl use warnings; use strict; use POSIX qw(strftime); use File::Copy; my $output_tag = strftime(".%Y%m%d%H%M", localtime); my $failid='/home/rdd/script/konf.aa'; my $kpv = strftime(".%Y%m%d", localtime); my $kat='/home/rdd/archive/rwa'.$kpv; my (@files, $file, $folder_name); if (open(FAILIDcnt, $failid)) { while(my $input = ) { chomp($input); my $output = $input; $output =~ s/\.txt//; $output .= $output_tag; open(IF, '/home/rdd/'.$input) or next; open(OF,'> /var/www/html/rwa_test/input/'.$output) or die "Can't open $output: $!"; open(OF,'> /home/rdd/archive/copy/'.$output) or die "Can't open $output: $!"; while(my $line = ) { last if $line =~ /^-{19}/; $line =~ s/,/./g; $line =~ s/\t/;/g; print OF "$line"; } close(OF); close(IF); system ("gzip /home/rdd/archive/copy/* "); if (!-e $kat) { mkdir $kat; } else { if (!-d $kat) { die "$kat already exists and is not a folder"; } } opendir(DIR, "/home/rdd/archive/copy/") or die "Can't Open Current Directory: $!"; @files = grep ~ m/^S.\w{2}/, readdir(DIR); close DIR; foreach $file(@files){ if($file =~ m/^S.(\w{2})/){ $folder_name = $1; mkdir ("$kat/$folder_name"); move ($file,"$kat/$folder_name/") or warn "Cannot move $file $!\n"; } } } close (FAILIDcnt); }