Discussion Locked

BATCH/SCRIPT FILES COMMAND

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a batch file that runs at a command prompt that goes along the lines of:

cd test
del *.*

I need this to run without any user intervention but as you'll know doing a del *.* then stalls the batch file as it waits for the user to push Y to confirm the deletion.
Is there a command I can use in the DOS batch file to allow the "Y" to be sent automatically so the files are deleting without intervention?

13 replies

by gyrfalcon2138

What might be a better idea (slightly less dangerous and all that) is if at the prompt, you use the command:

del test /f /q /s

This will delete all the data in the Test directory, this will force it to delete read only files (/F), do it quietly without asking confirmation (/Q) and delete all data in subdirectories (/S). del *.* /F /Q /S has that much more potential to completely wreck your windows install, and hopefully your situation does not call for such a blunt instrument.

by mozster

I get invalid switch errors when I try and do this.
Should have mentioned its under a Win98 client so will be that version of the DOS shell that this batch file needs to run under.

I take it the new switches /f /q /s are for an XP client?

by Member 25348569

del /f/q/s is definitely the Windows 2K/XP syntax.

one way - but a bit clunky.

echo y > temp.txt
cd test
del *.* < ..\temp.txt
cd..
del temp.txt

by davebkelly

All you need to do is use the /q switch. In effect, instead of doing a cd. just define the path you want to delete:

c:\test\*.* /q

This will delete the files within the "test" directory ONLY without asking for confirmation.

If you use:

c:\test\*.* /q /s

This will delete all files in the "test" directory AND the subfolders but will leave the folders intact.

Hope this helps.

This discussion is closed to new replies.