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