Deleting a directory structure

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

Deleting a directory structure

#1 Post by balubeto » 09 May 2012 01:00

HI

With the command prompt of Windows 7 SP1, how do I delete a directory structure with their files without deleting the name of the root directory?

THANKS

BYE

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Deleting a directory structure

#2 Post by foxidrive » 09 May 2012 01:25

Untested: syntax is: delfolder.bat "c:\test folder"


Code: Select all

@echo off
pushd "%~1"&&(rd "%~1" /s /q 2>nul&popd)

balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

Re: Deleting a directory structure

#3 Post by balubeto » 09 May 2012 01:44

foxidrive wrote:Untested: syntax is: delfolder.bat "c:\test folder"


Code: Select all

@echo off
pushd "%~1"&&(rd "%~1" /s /q 2>nul&popd)


Ok.

THANKS

BYE

Post Reply