Computing.Net > Forums > Windows 2000 > Batch file to delete all the folder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to delete all the folder

Reply to Message Icon

Name: Manny
Date: September 11, 2002 at 06:08:16 Pacific
OS: Windows 2000 Server
CPU/Ram: Dual P3 933
Comment:

How can I delete all the folders inside of a public shared folder and leave just the ones I want to stay with a batch file? I already tried to use rd command but it deletes all the folders including the one I'm sharing.



Sponsored Link
Ads by Google

Response Number 1
Name: Curt R
Date: September 11, 2002 at 07:41:50 Pacific
Reply:

Then you must be writing the batch file wrong. Let's say you have the shared folder: \\server_name\share with several folders underneath it. ex: folder1, folder2 folder3 You want to delete folder1 and folder3 but not folder2. Here's how I would write the batch file:
NOTE: I'm making an assumption here...that you are running the batch file on the computer that has the folders on it.

***begin batch file***

@echo off
rem first delete any files in target folders
cd \share\folder1
del /q *.*
cd \share\folder3
del /q *.*
rem now delete the folders
cd \share
rd folder1
rd folder2
rem that's it, you're done

***end batch file***

Now, you could use variables so that you could run the batch file from the command prompt and tell it the name of the folders you wish to delete while typing the batch file name to run it.
ex: (we'll call the batch file 'deldir.bat'
deldir folder1 folder2

This is a little trickier to setup than the batch file example I put in above and if you don't know how to use variables, well, just leave it alone. As long as it's the same folders you need to delete every time, the above example will work just fine.


0

Response Number 2
Name: Manny
Date: September 11, 2002 at 08:23:33 Pacific
Reply:

We have a share so that everyone can upload anything (open share with full rights). I want to clear that share daily but leave 2 folder on it (my personal 2 folders). The folder name is SHARE and I want to clear everything on it including all folders and files exept this 2 folders. Any idea?


0

Response Number 3
Name: Jinx©
Date: September 11, 2002 at 10:09:16 Pacific
Reply:

Manny, the easiest way we found during experimentation in school to accomplish what you ask, was to create a simple .BAT that added the ATTRIB +H to all things we didn't want removed, then DEL *.*, then ATTRIB -H to the things we had hidden to end the .BAT. It has worked every time we tried, but nobody has put this into practical application yet. You could attempt this procedure, but be sure to create dummy folders and files first to experiment with until you have the .BAT the way you want it :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Batch file to delete all the folder

Batch file to delete the temp files www.computing.net/answers/windows-2000/batch-file-to-delete-the-temp-files/33636.html

Batch files www.computing.net/answers/windows-2000/batch-files/53047.html

batch file to delete www.computing.net/answers/windows-2000/batch-file-to-delete-/20477.html