Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Deleting folders based on name.

by fazedandconfused (Novice)
on Oct 21, 2010 at 08:54 UTC ( #866508=note: print w/ replies, xml ) Need Help??


in reply to Deleting folders based on name.

Thanks for the replies.

As I couldn't access PerlMonks yesterday I ended up finding a completely different way of doing it.

#!/usr/local/bin/perl use warnings; use strict; use File::Find::Rule; use Date::Calc qw(Delta_Days); use File::Path qw(remove_tree); my $path="D:/FSA/Recordings/"; my @folders = File::Find::Rule->directory->in( $path ); foreach my $i (@folders){ if ($i =~ /[0-9]{4}/) { my $folder = substr($i,-4,4); my $month = substr($folder,0,2); my $year = substr($folder,2,2); my $folderyear = "1" . $year; my @folderdate = ($folderyear, $month, 01); my($curday, $curmonth, $curyear) = (localtime)[3,4,5]; my @curdate = ($curyear, $curmonth + 1, $curday); my $difference = Delta_Days(@folderdate, @curdate); if ($difference > 93) {remove_tree $i;} }; }


Comment on Re: Deleting folders based on name.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://866508]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2015-07-07 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls