From the above code if i commentout the pattern matching lines and i am able to zip all the folders in the E:drive, but when i do pattern match the folders with the yesterdays date and previous months yesterdays date, i unable to zip the specific dated files Monks,Appriciates for your attention for this post and kindly guide me for achiving this task.Thanks in Advance#!/usr/bin/perl use POSIX; use Utils; use ReadConfigFile; use FileHandle; $ConfigFile="E:\\rajtest\\xxx\\yyy\\data\\lib\\test.ini"; print "$ConfigFile\n"; $oConfigFile=ReadConfigFile::new($ConfigFile); if (not defined $oConfigFile){ die ("ConfigFile $ConfigFile cannot be accessed"); } $DirCoolOut=$oConfigFile->{DirOut}; print "$DirOut\n"; $AbsWinZip=$oConfigFile->{AbsWinZip}; print "$AbsWinZip\n"; $DirBakCoolOutZip=$oConfigFile->{DirBakCoolOutZip}; print "$DirOutZip\n"; $DirBakZipLog=$oConfigFile->{DirBakZipLog}; print "$DirBakZipLog\n"; CheckDir($DirBakCoolOutZip,"CREATE"); CheckDir($DirBakZipLog,"CREATE"); die ("Invalid winzip application") if not defined $Abs +WinZip; die ("Backup location $DirBakCoolOutZip") if not -e $DirBakCo +olOutZip; die ("Invalid Backup log location $DirBakZipLog") if not -e $DirBakZi +pLog; #open(FH,$DirCoolOut) or die "can't find the directory $!\n"; #while($line = <FH>) { #chomp $line; $path = $DirOut; opendir(D,"$DirCoolOut") or die "can't open the directory $!\n"; my @folders = grep {(!/^\./) && (!/^\.\./) } readdir(D); $winzip = "$AbsWinZip"; $now = localtime(); #print "$now\n"; %months = ("jan" => 1,"Feb" => 2,"Mar" => 3,"Apr" => 4,"May" =>5,"Jun" + =>6,"Jul"=>7, "Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec" =>12); @now = split(" ",$now); $month = $months{$now[1]}; $year = $now[-1]; $date = $now[2]; $yesterdaydate = $date - 1; $yesterdaydate = sprintf("%.2d",$yesterdaydate); $month = sprintf("%.2d",$month); $date = sprintf("%.2d",$date); $dateformat = "$year$month$yesterdaydate"; $Yesterdayzip = $dateformat; print "$Yesterdayzip\n"; #print "$dateformat\n"; $prevmonth = $month-1; $prevmonth = sprintf("%.2d",$prevmonth); $premonthdate = "$year$prevmonth$yesterdaydate\n"; $previousmonthzip = $premonthdate; print "$previousmonthzip\n"; foreach $file (@folders) { #print "$file\n"; $abspath = "$path$file"; $abspath1 = "$path$Yesterdayzip"; if($abspath =~ /$path$Yesterdayzip/) { system("\"$winzip\" -P $abspath.zip $abspath"); } if($apspath =~ /$previousmonthzip/) { system("\"$winzip\" -P $abspath.zip $abspath"); } #$abspath2 = "$path$$previousmonthzip"; #print "$abspath\n"; #system("\"$winzip\" -P $abspath.zip $abspath"); #system("\"$winzip\" -P $abspath.zip $abspath"); #system("\"$winzip\" -P $abspath1.zip $abspath"); #system("\"$winzip\" -P $abspath2.zip $abspath"); }
In reply to Unable to zip the folders which are created on yesterday and the previous month folder for the same yesterdays date. by perladdict
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |