Page 1 of 1 1
Topic Options
#71921 - 2002-11-29 10:27 AM Can someone please check this script
kncowans Offline
Getting the hang of it

Registered: 2000-11-11
Posts: 98
Loc: Doncaster, UK
Hello all

I am trying to write a small script to delete any sub folders that do not correspond with a given name in the script.

Everytime I run it it deletes all the folders, not just the ones that do not match the given name.

I have enclosed the script below.

Any suggestions?

Thanks in advance

code:
  

$DirToEmpty = "N:\TestDir"

CD $DirToEmpty

If @Error <> 0

Goto End

EndIf


Gosub EmptyDir

Exit


:EmptyDir

Dim $SubDir

$Filename = Dir("*.*")

While $Filename <> "" AND @Error = 0

If $Filename <> "TestDir"

DelDir($Filename)

EndIf

$Filename = Dir()

Loop

_________________________
Kevin Cowans Senior ICT Technician The Armthorpe School

Top
#71922 - 2002-11-29 10:31 AM Re: Can someone please check this script
Jochen Administrator Offline
KiX Supporter
*****

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

run a test round including somewhere

$FileName ?

in your loop

You'll see why it deletes all [Big Grin]
_________________________



Top
#71923 - 2002-11-29 10:33 AM Re: Can someone please check this script
kncowans Offline
Getting the hang of it

Registered: 2000-11-11
Posts: 98
Loc: Doncaster, UK
Hello

There is a Return and also an End label but it seems to have got left off when I cut and pasted the script.

Thanks

Kevin
_________________________
Kevin Cowans Senior ICT Technician The Armthorpe School

Top
#71924 - 2002-11-29 08:58 PM Re: Can someone please check this script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kevin, please could you post your actual code.

there is no way the above can work.
if it's full, please take the sub out of the main loop and place it elsewhere.
_________________________
!

download KiXnet

Top
#71925 - 2002-11-29 10:48 PM Re: Can someone please check this script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might also want to utilize any of the DIR...() UDFs that are posted in the UDF Forum instead of reinventing the wheel.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

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

Generated in 0.053 seconds in which 0.024 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