Page 1 of 1 1
Topic Options
#3103 - 2000-05-25 12:06 AM How to auto delete files
Anonymous
Unregistered


I'm running NT 4.0 SP4. I need the ability to delete files that are older than (today - two weeks). Has anyone done this via KiXtart?
Top
#3104 - 2000-05-25 12:38 AM Re: How to auto delete files
Anonymous
Unregistered


Sorry. I didn't look far enough in the opened cases. There are two responses in Aug and Oct 99 that answer this question somewhat.

Top
#3105 - 2000-05-24 01:06 PM Re: How to auto delete files
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I haven't looked into the open cases and so this might be redundant, but it was fun, so...

code:

break on
cls
; Date delete test


; Directory to look in.
$filename=dir("*.*")
"Please enter the date in the format YYYY/MM/DD"
? "Eg: 2000/05/10 - must have leading zeros : "
gets $date2


? "These are the files that are older than this $date2:"
while $filename<>"" and @error=0
if $filename="." $filename=dir() endif
if $filename=".." $filename=dir() endif


; get file time/date
$date=getfiletime("$filename")
$date=substr($date,1,10)


; Compare to $date2
if $date<$date2
? "$filename"
; del("$filename")
endif


; get next file
$filename=dir()
loop


Basically it will compare the user input date with the date on all the files in the specified directory and tell you which are older. I have commented out the DEL line.

Change the DIR at the top from *.* to a full path, ie C:\files\*.txt

Not a lot of error checking and I would leave the DEL commented the first time you use it.

cj

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1321 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.328 seconds in which 0.211 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org