0

In a GWBasic program I wish to delete all files *.??8 in the working directory AND sub-directories. The 'Kill' command in GWBasic allows no switches and doesn't get into subdirectories. If I shell "del *.??8 /S" (or "del /S *.??8") I get the error message 'Invalid switch -/S'; even though 'del *.??8 /S' (or 'del /S *.??8') works from the DOS prompt. I am using WinXP with all updates. Can anyone tell me how to delete these files from within a Basic program?
Thanks.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by kanga85
0

Wrong forum.

GWBASIC doesn't have a recursive KILL command. You'll have to write a subroutine that does it yourself.

  1. Use FILES to get all the file names in the target directory.
  2. For each filename:
    • if it is a directory (name is followed by "<DIR>", for example "C:\FOO\MYSUB<DIR>") then recurse.
    • otherwise use KILL
  3. When done, RMDIR the current directory

Remember to specify an error handler or turn it off or use RESUME before trying to delete files (since the OS may disagree and cause an ERROR to be signaled).

I wonder if SHELL "DEL/S ..." would work? The specification specifically refers to COMMAND.COM, which I think isn't supposed to have the /S option. You could also try SHELL "RD/S/Q" (which is an XP command).

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.