#!/usr/bin/perl

system("find /oldmail -type f |grep \/Maildir\/new\/ > /msg.txt");
open(M,"/msg.txt");
my $path="";
while(<M>){
	s/\r\n//g;
	s/\n//g;
	my @tmp = split('/',$_);
	$path = '/jdnewmail/'.$tmp[1].'/'.$tmp[2].'/mailbox';
	system("mkdir -p $path");
	open (A,$_);
	open (B,"> $path\/$tmp[5].new");
	my $i=0;
	while (<A>){
		if ($i<5){
			$i++;
			next;
		}
		print B $_;
	}
	close(B);
	close(A);
}
close(M);
