Solved

A batch file to delete files from a network share... ?

Posted on 2008-10-14
5
609 Views
Last Modified: 2012-05-05
Hi experts,

I have a quick question. I need a batch file to delete files from a network share. I tried mapping the drive as f.e. letter X: than cd x:\filder   but it just does not want to work for me.
Is there some other way of doing that ? First option (mapping and logging in i was able to manage but cannot sort this issue out)

Thank you for your help.

Pawel
0
Comment
Question by:Pawel-Blazejewicz
  • 2
  • 2
5 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 22710244
something like

@echo off

:delete
net use h: /delete
if errorlevel 1 goto delete

:map
net use h: \\server\share
if errorlevel 1 goto map

:success
echo Remapping of H: successfully completed.


taken from http://www.hardforum.com/archive/index.php/t-1048024.html
0
 

Author Comment

by:Pawel-Blazejewicz
ID: 22710355
Hi there, thanks for your fast answer but what I am looking for i a way of deleting files stored on the netowrk share not the share itself. Lest say I have \\server\folder\folder2\files   and I want to delete all files stored on Folder2 using a batch file or a windows script does not matter how to be honest, just something that will do this job for me.

0
 
LVL 31

Expert Comment

by:James Murrell
ID: 22710367
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 125 total points
ID: 22710459
The problem is in your CD command, which cannot change both the drive and path at the same time.

The right way is this:
   NET USE X: /DELETE
   NET USE X: \\Server\Share
   X:
   CD \Folder2
   DEL *.*
0
 

Author Closing Comment

by:Pawel-Blazejewicz
ID: 31505828
Thank you
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question