Hi Friends,
I am new to perl. I am trying to work on a perl script which will delete only those files on a particular path which are older than 7 days in terms of accessed date of the files. However, it seems not working. But, when i put a condition "M" it does work for a modified date condition. Below is the code. Please suggest what should I do. Thanks for your help and suggestion.
#!/usr/local/bin/perl-w my $username = getlogin; my $userpath = "C:/Users/$username/AppData/Local/Temp/Data"; print $username; opendir (DIR, "$userpath") || die ("Unable to open directory"); @files=readdir(DIR); closedir(DIR); foreach $file (@files) { if (-A "$userpath/$file" > 7) { print ("$file\n"); print $userpath."/".$file; unlink $userpath."/".$file; print "File deleted successfully\n"; } }
In reply to Script to delete only those files on a path whose accessed date is more than 7 days by abhi_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |