Solved

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

Posted on 2008-10-14
5
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

726 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