Skip to main content

The best Solution: e.g. i want to delete all files and sub-directories of parent directory lets say "C:\Users\Desktop\New folder". The easy way is create batch file of below three commands.

cd C:\Users\Desktop\New folder
del * /S /Q rmdir /S /Q "C:\Users\Desktop\New folder"

cd C:\Users\Desktop\New folder\

del * /S /Q

rmdir /S /Q "C:\Users\Desktop\New folder"

Here first it will clean all files in all sub-directories and then cleans all empty sub-directories. Since current working directory is parent directory i.e."\New folder", rmdir command can't delete this directory itself.

-Anna

The best Solution: e.g. i want to delete all files and sub-directories of parent directory lets say "C:\Users\Desktop\New folder". The easy way is create batch file of below three commands.

cd C:\Users\Desktop\New folder
del * /S /Q rmdir /S /Q "C:\Users\Desktop\New folder"

Here first it will clean all files in all sub-directories and then cleans all empty sub-directories. Since current working directory is parent directory i.e."\New folder", rmdir command can't delete this directory itself.

-Anna

The best Solution: e.g. i want to delete all files and sub-directories of parent directory lets say "C:\Users\Desktop\New folder". The easy way is create batch file of below three commands.

cd C:\Users\Desktop\New folder\

del * /S /Q

rmdir /S /Q "C:\Users\Desktop\New folder"

Here first it will clean all files in all sub-directories and then cleans all empty sub-directories. Since current working directory is parent directory i.e."\New folder", rmdir command can't delete this directory itself.

Source Link
Annasaheb
  • 399
  • 3
  • 2

The best Solution: e.g. i want to delete all files and sub-directories of parent directory lets say "C:\Users\Desktop\New folder". The easy way is create batch file of below three commands.

cd C:\Users\Desktop\New folder
del * /S /Q rmdir /S /Q "C:\Users\Desktop\New folder"

Here first it will clean all files in all sub-directories and then cleans all empty sub-directories. Since current working directory is parent directory i.e."\New folder", rmdir command can't delete this directory itself.

-Anna