Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I try to run mkdir build to create a build directory, if the directory already exists, this error is thrown: A subdirectory or file build already exists.. I need to delete and overwrite this directory. What is the command for that?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

You can delete the build directory with

rd /s /q build

or

if exist build rd /s /q build
share|improve this answer

I don't think it is possible to use the mkdir command to do that natively (though if you were will to do a bit more scripting, it would be possible).

A simple alternative is the following command in powershell:

New-Item path -type directory -force

Where path is something like C:\users\name\build

For more on New-Item see: http://technet.microsoft.com/en-us/library/ee176914.aspx

share|improve this answer
    
I can't execute powershell as I'm calling this from a rake script. –  Shawn Mclean Aug 19 '12 at 21:29

You can try the rd command to remove the directory. You have to ensure the directory is empty first though.

share|improve this answer
    
This throws an error if there are elements in the directory. –  Shawn Mclean Aug 19 '12 at 21:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.