Page 2 of 2 <12
Topic Options
#3615 - 2000-07-26 02:00 PM Re: Date check then delete
Anonymous
Unregistered


Hi Fuentez, Jochen, etc.

First I want to thank you for the good and very helpfull responses !!!

thanx for your responses.... I'm now trying to get the script working. The only thing I now experience is a : File not found message when it wants to create the txt-file.(SHELL "%comspec% /c dir /b $dirarray[$counter] > $dirarray[$counter].txt")
Any suggestions what it can be ? When I use it with the script Bryce wrote, it works fine ! But i'm more interested in the Delroutine Fuentez wrote...

Again thx,
Jasper

Top
#3616 - 2000-07-26 02:46 PM Re: Date check then delete
Anonymous
Unregistered


I got the same error - shit. I felt so guilty I set up a test and wrote the whole damn thing so it works. Serves me right for not testing..
Sorry! I'll email it to you... And I see you don't have e-mail. Well then, here it goes again:

>>Note:
Appearantly, kix want you to stuff the value of $dirarray[$counter] into a seperate variable before you use it (in a SHELL at least).
So:
$now=$dirarray[$counter]
and THEN
SHELL '%comspec% /c dir /b $now >> $now.txt'
works just fine...

---------------------------------------------
;run the script from the root of your dir-structure

BREAK ON

DIM $dirarray[4]
$dirarray[0]="directory"
$dirarray[1]="directory1"
$dirarray[2]="directory2"
$dirarray[3]="directory3"

$countermax=4 ;(total array + 1)

$counter=0
WHILE $counter<$countermax
$now=$dirarray[$counter]
SHELL '%comspec% /c dir /b $now >> $now.txt'
$counter=$counter+1
LOOP

$counter=0
WHILE $counter<$countermax
GOSUB delroutine
$counter=$counter+1
LOOP

? "Check done"
GET $none
EXIT


;------------------------DELROUTINE---------------------
:delroutine
$now=$dirarray[$counter]
OPEN (6,"$now.txt")
$currentfile=READLINE(6)

WHILE ($currentfile<>"")

$date_old=getfiletime("$now\$currentfile")
$year_old=VAL(substr($date_old,1,4))
$month_old=VAL(substr($date_old,6,2))
$day_old=VAL(substr($date_old,9,2))

IF (VAL(substr(@date,1,4))-$year_old)>0 AND ($month_old<12) GOTO decided ENDIF
IF (VAL(substr(@date,1,4))-$year_old)>0 AND ($month_old=12) AND (@monthno>1) GOTO decided ENDIF
IF ((@monthno-$month_old)>1) GOTO decided ENDIF
IF ((@monthno-$month_old)=1) GOTO decided ENDIF
GOTO endloop

:decided
DEL "$now\$currentfile"
:endloop
$currentfile=READLINE(6)
LOOP

CLOSE (6)
DEL "$now.txt" ;delete the directory-content-file when done.
RETURN
;-------------------------------------------------------------

[This message has been edited by Fuentez (edited 26 July 2000).]

Top
#3617 - 2000-07-26 04:20 PM Re: Date check then delete
Anonymous
Unregistered


Hi Fuentez,

i've got it working... !!! The only thing i walk into is the following:

When the script wants to write to the txt-file, it is done correctly..., except it is overwriting each time it writes to the txt-file...(it's not adding lines to the txt-file)

Grt,
Jasper

Top
#3618 - 2000-07-26 04:34 PM Re: Date check then delete
Anonymous
Unregistered


Yes, but since the text-file gets made, and after deleted that wouldn't be a problem, right? What textfile do you wish to add to?
The directory-contents get read everytime you run the script and every file gets checked, so adding to the text-file would not be needed. I think..
I'm sure about not being sure what you mean, could you be more specific?

- Ramon

Top
#3619 - 2000-07-26 04:45 PM Re: Date check then delete
Anonymous
Unregistered


I mean that when the command -
SHELL "%comspec% /c dir /s/b $dirarray > directory_tree.txt" - is executed, the txt-file will be overwritten with the new directory structure.

But.., i've got it working now... ripped out the dirarray.

Thanx very much for getting me on the good path !

Top
#3620 - 2000-07-26 05:12 PM Re: Date check then delete
Anonymous
Unregistered


AAARRG! Do you have multiple subdirs then?
I mean DIR>DIR>FILES?
Because the script only goes into one layer. So for the following structure the script would look like this:
ROOT>DIR1>FILES1
ROOT>DIR2>FILES2
ROOT>DIR3>FILES3

DIM $dirarray[3]
$dirarray[0]="dir1"
$dirarray[1]="dir2"
$dirarray[2]="dir3"

If you do have multiple subdirs then the script could be modified but I think that would be a beautifull place to start getting aquainted with Kix! *grin*

Top
#3621 - 2000-07-26 06:55 PM Re: Date check then delete
Anonymous
Unregistered


I already did this......, with the dir command...

Sorry......*grin*

Top
#3622 - 2000-07-27 04:08 PM Re: Date check then delete
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Frrrreeeeestyla,

if you ever want to append to a file use '>>'
instead of '>'

cu

_________________________



Top
#3623 - 2000-07-27 08:35 PM Re: Date check then delete
Anonymous
Unregistered


Jochennnn,

thanx for the tip...., I keep it in mind.

CU,
Jasper

Top
#3624 - 2001-12-19 05:31 PM Re: Date check then delete
T Offline
Lurker

Registered: 2001-12-18
Posts: 2
Thanks I guess I didn't go back far enough.
Top
Page 2 of 2 <12


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

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.027 seconds in which 0.011 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