Question

What I would like to do in my batch file is delete ALL the contents of the containing directory AND the directory itself. Currently I am using the following command:

rmdir ..\dir /S /Q & exit

This works in that it deletes ALL of the contents in dir including the batch file but it fails to delete the directory, dir. Is there a way to do this while deleting the dir also? Essentially what I would like to do is create a batch script that would reside inside a ZIP file and deletes everything that gets created from unzipping the file. The above command still leaves behind an empty directory.

Was it helpful?

Solution

What about the following?

cd ..
rmdir .\dir /S /Q & exit

You can't delete a directory which is occupied by a running process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top