Re: [PHP] Unlink file older then 7 days

2007-07-20 Thread Richard Lynch
Did you actually READ my previous post that you replied to?...

On Wed, July 18, 2007 1:29 am, [EMAIL PROTECTED] wrote:
> Ok thanks everyone...
>
> I need to throw in a wildcard, how would I do that.. I have this so
> far.
> which dont work.
>
>  $filename = '/home/public_html/client/test/*.txt.asc';
...
[snip]

>> I think finding all the .txt.asc files would best be handled by
>> http://php.net/glob unless your PHP version is too old and you need
>> to
>> http://php.net/opendir and http://php.net/readdir to look at each
>> file
>> in turn...

PHP 5:
http://php.net/glob

PHP 4:
http://php.net/opendir
http://php.net/readdir

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-17 Thread Paul Scott

On Wed, 2007-07-18 at 07:29 +0100, [EMAIL PROTECTED] wrote:
> I need to throw in a wildcard, how would I do that.. I have this so far. 
> which dont work.

foreach(glob("*.asc.txt") as $files)
{
unlink($files);
}

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Unlink file older then 7 days

2007-07-17 Thread chris

Ok thanks everyone...

I need to throw in a wildcard, how would I do that.. I have this so far. 
which dont work.





Thankyou


- Original Message - 
From: "Richard Lynch" <[EMAIL PROTECTED]>

To: "Stut" <[EMAIL PROTECTED]>
Cc: "Suhas Pharkute" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; 


Sent: Wednesday, July 18, 2007 2:17 AM
Subject: Re: [PHP] Unlink file older then 7 days





On Mon, July 16, 2007 8:40 am, Stut wrote:

Suhas Pharkute wrote:

http://us.php.net/manual/en/function.fileatime.php

$filename = 'somefile.txt';
if (file_exists($filename) && fileatime($filename) <
(time()-(7*24*60*60)) )
{
   unlink($filename);
}

Read docs!


You too! The OP wanted a way to "check the age of all files". The
fileatime function will return when the file was last accessed.
Accessing a file is not usually deemed to affect its age, modifying it
is. The filemtime function is what the OP wants.


Unless he wants filectime, for when the file was created, even if it's
been modified in the past week...

"older" could mean that, in some contexts...

I think finding all the .txt.asc files would best be handled by
http://php.net/glob unless your PHP version is too old and you need to
http://php.net/opendir and http://php.net/readdir to look at each file
in turn...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-17 Thread Richard Lynch


On Mon, July 16, 2007 8:40 am, Stut wrote:
> Suhas Pharkute wrote:
>> http://us.php.net/manual/en/function.fileatime.php
>>
>> $filename = 'somefile.txt';
>> if (file_exists($filename) && fileatime($filename) <
>> (time()-(7*24*60*60)) )
>> {
>>unlink($filename);
>> }
>>
>> Read docs!
>
> You too! The OP wanted a way to "check the age of all files". The
> fileatime function will return when the file was last accessed.
> Accessing a file is not usually deemed to affect its age, modifying it
> is. The filemtime function is what the OP wants.

Unless he wants filectime, for when the file was created, even if it's
been modified in the past week...

"older" could mean that, in some contexts...

I think finding all the .txt.asc files would best be handled by
http://php.net/glob unless your PHP version is too old and you need to
http://php.net/opendir and http://php.net/readdir to look at each file
in turn...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-16 Thread Ray


-Original Message-
From: <[EMAIL PROTECTED]>
To: 
Date: Mon, 16 Jul 2007 14:25:47 +0100
Subject: Re: [PHP] Unlink file older then 7 days

> How would I use fileatime to check if the file is older then 7 days?
> 
> 
> 
> 
something like:
$access = fileatime (c:\path\to\file);//assuming windows server
if ((time()-$access)>(7*24*60*60)){
do whatever with old files
}

off the top of my head. 
There are other ways to do it.
Ray

> 
> >> I have a directory with .txt and .txt.asc files.
> >>
> >> What I want to do is..
> >>
> >> Check the age of all files ending in .txt.asc
> >>
> >> and if the file *.txt.asc is older then 7 days
> >>
> >> delete thatfile.txt.asc and also thatfile.txt
> >>
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-16 Thread Stut

Suhas Pharkute wrote:

http://us.php.net/manual/en/function.fileatime.php

$filename = 'somefile.txt';
if (file_exists($filename) && fileatime($filename) < 
(time()-(7*24*60*60)) )

{
   unlink($filename);
}

Read docs!


You too! The OP wanted a way to "check the age of all files". The 
fileatime function will return when the file was last accessed. 
Accessing a file is not usually deemed to affect its age, modifying it 
is. The filemtime function is what the OP wants.


-Stut

--
http://stut.net/


On 7/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


How would I use fileatime to check if the file is older then 7 days?





>> I have a directory with .txt and .txt.asc files.
>>
>> What I want to do is..
>>
>> Check the age of all files ending in .txt.asc
>>
>> and if the file *.txt.asc is older then 7 days
>>
>> delete thatfile.txt.asc and also thatfile.txt
>>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-16 Thread Suhas Pharkute

http://us.php.net/manual/en/function.fileatime.php

$filename = 'somefile.txt';
if (file_exists($filename) && fileatime($filename) < (time()-(7*24*60*60)) )
{
   unlink($filename);
}

Read docs!

Suhas


On 7/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


How would I use fileatime to check if the file is older then 7 days?





>> I have a directory with .txt and .txt.asc files.
>>
>> What I want to do is..
>>
>> Check the age of all files ending in .txt.asc
>>
>> and if the file *.txt.asc is older then 7 days
>>
>> delete thatfile.txt.asc and also thatfile.txt
>>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Unlink file older then 7 days

2007-07-16 Thread Stut

[EMAIL PROTECTED] wrote:

How would I use fileatime to check if the file is older then 7 days?


You want filemtime not fileatime.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-16 Thread chris

How would I use fileatime to check if the file is older then 7 days?






I have a directory with .txt and .txt.asc files.

What I want to do is..

Check the age of all files ending in .txt.asc

and if the file *.txt.asc is older then 7 days

delete thatfile.txt.asc and also thatfile.txt



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unlink file older then 7 days

2007-07-14 Thread Ray
On Saturday 14 July 2007 9:16:06 pm [EMAIL PROTECTED] wrote:
> I have a directory with .txt and .txt.asc files.
>
> What I want to do is..
>
> Check the age of all files ending in .txt.asc
>
> and if the file *.txt.asc is older then 7 days
>
> delete thatfile.txt.asc and also thatfile.txt
>

look at these functions (and also related functions, the bar on the right hand 
side):
http://ca3.php.net/manual/en/function.opendir.php
http://ca3.php.net/manual/en/function.fileatime.php
http://ca3.php.net/manual/en/function.unlink.php
HTH 
Ray

>
> Thanks
> Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Unlink file older then 7 days

2007-07-14 Thread chris
I have a directory with .txt and .txt.asc files. 


What I want to do is..

Check the age of all files ending in .txt.asc 

and if the file *.txt.asc is older then 7 days 


delete thatfile.txt.asc and also thatfile.txt


Thanks
Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php