Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How do I find and delete files based on age?

by davorg (Chancellor)
on Feb 26, 2007 at 14:58 UTC ( [id://602136]=note: print w/replies, xml ) Need Help??


in reply to How do I find and delete files based on age?

(Please use a more descriptive title for your questions)

In pseudocode, your solution would be something like this:

  • Get date two weeks ago (using time and some basic arithmatic to subtract 14 day's worth of seconds)
  • Open directory handle with opendir
  • For each file read from the directory handle with readdir...
    • Ignore file unless is starts with DATE_ (check with a regular expression)
    • Parse date and time out of filename (using a regex)
    • If parsed date is less than the two week's ago date that you calculated at the start then delete the file
  • Read next file from directory handle
  • Comment on Re: How do I find and delete files based on age?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-16 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found