Delete a folder from a UNC path

August 5, 2009 at 05:09:48
Specs: Windows server 2003

I want to delete all the folders from a UNC path using batch.

Suppose i have 2 folders(JAR and WAR) inside //server1/Application UNC Path. Now i need to delete JAR and WAR from
Application folder. But i do not want to delete the Application directory.

Please help me wriing the batch file.

See More: Delete a folder from a UNC path

Report •

August 5, 2009 at 07:12:06
Why bother writing a batch file for a one-line task?

Type RD /? for help.

The command you want is

rd /s \\server1\application\jar

for the JAR folder and similarly for the WAR folder.

Report •

August 5, 2009 at 21:24:58
i just gave the example of JAR and WAR. but actually application folder has lots of subfolders whose names are keep on chnaging. In that case i can not RD here.

Report •

August 5, 2009 at 21:53:14
FIDO [for in do]

@echo off & setLocal EnableDELAYedExpansion

pushd \\server1\application

for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
if "%%a" neq "dir2keep" (
rd /s "%%a"

If at first you don't succeed, you're about average.


Report •

Related Solutions

Ask Question