mardi 31 mars 2015

Finding Missing Files with Perl Script [Directory Entery and Export Protocol]

I exported some Files and after the Export there are actually 2 Files missing. In the Protocol is written that i Exported 560 Files but I only got 558.


Now I want to check which File is missing. So I decided to try it with a Perl Script, even tho im pretty new to this.



#!C:\Strawberry\perl\bin\perl.exe

#Pragmas
use strict;
use warnings;


my $Dir = 'Directory to the Exported Files';
my $Export = 'Directory to the Export Protocol File';
my $Expo;

#Open Directory
opendir( DIR, $Dir ) || die "can't opendir $Dir: $!";
my @files = readdir(DIR);
closedir(DIR);

#Open Export File
open( DATEI, "$Export" ) or die $!;
while (<DATEI>) {
$Expo = $Export . $_;
}
close(DATEI);

#Comparing which File is missing.....[Not working obviously :(]
foreach my $file (@files) {
if ( $Expo !~ m/$file/ ) {
print "$file\n";
}

}


The Export Protocol Looks like this...



DATEDATEDATE - USER EXPORT, counter '0000000001': Object: 'FILENAME' got exported. DATEDATEDATE- USER EXPORT. File: 'D:\Work\Export_Import\Export\FILENAME.xml' exported.



The only important Thing is the Filename :]


I hope you understood my Problem ...


Thank you!


Aucun commentaire:

Enregistrer un commentaire