Delete all files ...txt

Blitz3D Forums/Blitz3D Beginners Area/Delete all files ...txt

Im having trouble getting this right.
I want to delete all text files in one directory. Can you please help me out with the right command line to do this?
Thanks.

I never tried it, but shouldn't
DeleteFile "*.txt"
do the job, or doesn't Blitz support that wildcards...

(Example above should if it works delete all files in the current dir)

Unfortunately I have tried that and it hasn't worked.
And I'm using blitzplus if that makes a difference.
Thanks

Then I guess it can't be done in one command and that Blitz does not support Wild Cards... Just a moment, I have a piece of code I use in The Fairy Tale to empty the game's temp directory.... I don't think Blitz+ will have any trouble handling that piece of code

I have to note this code is directly copied so it contains a few Globals that only have effect in my game, but I'm sure you can work something with the documention and my code:

Function CleanUpTempFiles()
Local D% = ReadDir(TempFileDirectory$)
Local F$
Repeat
F$ = NextFile(D%)
If F$ = "" Then Exit
F$ = TempFileDirectory$ + F$
If FileType(F$)>0 Then DeleteFile F$
If FileType(F$)<>0 And FileType(F$)<>-1 And F$<>TempfileDirectory+"." And F$<>TempFileDirectory$+".." Then
   RuntimeError "Could not delete temp file "+F$+". File could be damaged or be made 'Read-Only'"
   EndIf
Forever
CloseDir D%
End Function


You can try using the run command to run the operating system's delete command.

I probably have the syntax on the example below wrong...

run "del *.txt"

run "del *.txt"


That command doesn't work at all...
I once tried it on a semiliar way, with the "ExecFile" command using the "COMSPEC" environ, but for strange reasons it didn't work out...