Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a folder and all its content from the current directory?

This code that does not work:

@echo off  if exist output @set /p checkdir= Output directory found. Do you wish to overwrite it?:  if  /I %checkdir% == Y  deltree /s /output  pause 
like image 210
misctp asdas Avatar asked Oct 24 '11 06:10

misctp asdas


People also ask

Which command used to delete all files from current directory?

Answer: Use the rm Command Both commands will have the same effect, because current working directory doesn't matter when you use absolute path. Any path that starts with a forward slash / is an absolute path. The options have the following meanings: -r : Recursive remove.

How do I delete a full directory in Linux?

To permanently remove a directory in Linux, use either rmdir or rm command: For empty directories, use rmdir [dirname] or rm -d [dirname] For non-empty directories, use rm -r [dirname]


1 Answers

You were looking for this command:

RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path      /S      Removes all directories and files in the specified directory             in addition to the directory itself.  Used to remove a directory             tree.      /Q      Quiet mode, do not ask if ok to remove a directory tree with /S 

In your case just use /S ,it will delete the whole directory tree by first asking the user if it should proceed, i.e.- displaying the following output to the screen:

"folderName, Are you sure (Y/N)?"

where folderName is the name of the folder (and its sub-folders) you wish to remove.

Tested on Windows 7, 64 bit.

like image 103
weberik Avatar answered Sep 28 '22 23:09

weberik