Search code examples
batch-filebatch-processingdrive

Batch script used to delete all files and folders inside of a student drive (G)


Hello this is my first post so here goes nothing. I'm currently working on a task with a supervisor where he wants me to create a Batch script that will whip out all the contents in a student (G) drive. When I run this command it only deletes files. Folders and applications do not get removed at all.

This is what I put in my .bat script

forfiles -p "G:\" -s -m *.* /D -0 /C "cmd /c del @path"

Solution

  • How about just doing:

    rd G:\. /S /Q
    

    You could also pushd to the dir and then do the delete simply by using && operator to ensure the pushd command completes before executing the rd command.

    pushd G:\ && rd . /S /Q