#!/usr/bin/perl # # ---------- batch conversion of *.msg files to *.eml ------------------- # # Version 1.0. # # author: Dr. Michael J. Chudobiak, mjc@avtechpulse.com # # Feel free to modify this in any way you like. # # ---------------------------------------------------------------------- use strict; # ----------------- Start of Configuration ------------------------------ # Directory containing files to parse (full path, end with slash). my $input_dir = "/fileserver/officefiles/quotes/"; # Who should own the *.eml files? (user.group) my $file_ownership = "mjc.officestaff"; # location of the msgconvert.pl script my $script_location = "/var/www/html/cgi-perl/msgconvert.pl"; # ----------------- End of Configuration ------------------------------- # list the files in the directory opendir(DIR,$input_dir); my @entries = readdir(DIR); closedir(DIR); # examine each file foreach my $entry (@entries) { # work with *.msg files only next if ($entry !~ /\.msg$/i); # construct the full filenames of the old and new files my $msg_filename = $input_dir . $entry; my $eml_filename = $msg_filename; $eml_filename =~ s/\.msg$/\.eml/i; # If an *.eml file does not already exist from an earlier conversion, # convert the file. if (!(-e $eml_filename)) { my $command_to_execute = qq{$script_location "$msg_filename" > "$eml_filename"}; # The back-ticks execute a system command - in this case, the # single-file conversion script is run. print `$command_to_execute`; # Change the ownership on the new file to something appropriate $command_to_execute = qq{chown $file_ownership "$eml_filename"}; print `$command_to_execute`; } }