#!/usr/bin/perl -w use warnings; use strict; use File::Find; use File::Path; my $dir='D:\\TestDelete\Test'; print("$dir"); find \&unwanted,$dir; sub unwanted { if(-d $dir) { if ( ( -M $_ ) >2 &&(-M $_)<4) { print ("file exist"); rmtree($_) or die "could not rmdir '$File::Find::name' $!"; print("deleted"); } } }
The above code is working fine and deleting but before deleting am getting the below error msg Can't remove directory . (Permission denied) at D:\maestro\Testp2.pl line 15. I am ruunning the code in window server which has sep username and password to login. Kindly help me.
Update
Hi all,
My code is working fine as per my requirement .but the thing is am getting the error msg as mentioned above.
In reply to Can't remove directory-Permission denied by rrrrr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |