Solved

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

Posted on 2008-10-14
5
605 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 125 total points
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now