Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Delete Old Directories

by Anonymous Monk
on Oct 20, 2011 at 10:51 UTC ( #932620=note: print w/ replies, xml ) Need Help??


in reply to Re: Delete Old Directories
in thread Delete Old Directories

All that make sense, but if I have in this directory other directories like:

09052011 10152011 10162011 10172011 10182011 10192011 10202011
How could I compare these dates from the directory names if they are 45 days older than today's date. With the dates above I would have to delete 09052011 directory because its 45 days older than today's date.


Comment on Re^2: Delete Old Directories
Download Code
Re^3: Delete Old Directories
by choroba (Abbot) on Oct 20, 2011 at 12:21 UTC
    Your date format is different from the proposed one. To make things easy, you should be using this one:
    20110905 20111015 20111016 20111017 20111018 20111019 20111020
    Then, just generate the string for the day 45 days ago and remove everything lesser.
    How to find what that days' date was? How yould you proceed without a computer? Would you calculate the date, or just have a look into a calendar?
      This is exactly the right idea! The file names shown will sort with a simple string comparison based upon the text from the file name. I am at a loss as to how to make this more clear.

      Working with the filename is just much easier and more obvious than working with OS specific things like the -M file test.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2014-11-26 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (167 votes), past polls