Pages

3/25/2002

CONVERT NOVELL ADDRESS BOOK TO OUTLOOK

#NAB2CSV.PL
#3/20/2002
#convert Novell NAB formatted file to CSV file that can be imported into Outlook

#filenames & variables
$indir = 'c:\\work\\nab2csv\\nab';
$outdir = 'c:\\work\\nab2csv\\csv';

#Expressions to filter
my @filter = (
"^:::TAGMAP:::" ,
"CONVAPI" ,
"ICEMILLER\.COM" ,
"\.IMDR" ,
"OFFICE\.VENUS" ,
"first administrative group" ,
"^\"G>" ,
"^\"G<" ,
"^\"GT"
);


opendir(DIR, "$indir");
my @files = readdir(DIR);
closedir(DIR);

my $file;
my $keep;

foreach $file (@files) {
if ($file eq ".") {next};
if ($file eq "..") {next};
#input filename
my $infile = "$indir\\$file";
#output filename
my $newfile = $file;
$newfile =~ s/.NAB$/.CSV/gi;
$newfile = "$outdir\\$newfile";
open (OUT, ">$newfile");
#output NAB header to file
print OUT "::TAGMAP:::0FFE0003:***,Name,Business Phone,Department,Business Fax,E-Mail Address,First Name,Last Name,Title,Business Street,Business City,Business State,Business Country,Business Postal Code,E-Mail Type,Mailstop,Home Phone,Cellular Phone Number,Phone Number,Greeting,Owner,Company,Comments,User ID,Domain,Additional Routing,Post Office,GUID,NDS Distinguished Name,Network ID,\n";

open(LINES, "<$infile") or ( die "File error in:$infile");
my @lines = ;
close (LINES);

foreach $line (@lines) {
$keep = "yes";
foreach $filter (@filter) {
if ($line=~/$filter/gi) {
$keep = "no";
last;
}#end if $filter
}#end foreach $filter

if ($keep eq "yes") {
$line =~ s/INTERNET://gi; #remove INTERNET: prefix
$line =~ s/^\"UT\"/\"U\"/i; #make dist list entries user entries
print OUT $line;
}#end if $keep

}#end foreach $line
close (OUT);#close output file
}#end foreach $file

No comments: