Show if folder exist and delete it
Moderator: DosItHelp
Show if folder exist and delete it
Hello. i am new at batch so i need some help with script which check if there is a folder in my selected directory and if there is that folder then delete it.
Re: Show if folder exist and delete it
Something like this?
Code: Select all
@echo off
if exists "D:\UnwantedFolder" ( del /q "D:\UnwantedFolder" )
Re: Show if folder exist and delete it
AiroNG wrote:Something like this?Code: Select all
@echo off
if exists "D:\UnwantedFolder" ( del /q "D:\UnwantedFolder" )
Yes something like this. but i am getting message that folder was unexpected at this time
Re: Show if folder exist and delete it
There's a typo above, and the trailing slash checks for a folder as opposed to a file too.
RD is used for folders.
RD is used for folders.
Code: Select all
@echo off
if exist "D:\UnwantedFolder\" rd /s /q "D:\UnwantedFolder"
Re: Show if folder exist and delete it
Sorry, my mind was somewhere else when i made that post.
foxidrive's solution is the correct way.
for /l %%a in (1 1 100) do ( echo: I will reread my written text before i post it! )

foxidrive's solution is the correct way.
for /l %%a in (1 1 100) do ( echo: I will reread my written text before i post it! )
