PC Review


Reply
Thread Tools Rate Thread

Batch Delete Help

 
 
jeffbg123
Guest
Posts: n/a
 
      14th Jun 2007
I am trying to find a batch command that takes a directory and deletes
all files in that directory, along with subdirectories, leaving an
empty top level folder.

For instance I have a directory C:\test. In C:\test there are 5 .txt
files and another directory called C:\test\t2. In C:\test\t2 there are
7 mp3 files. I want a command that will delete all of the txt files,
all of the mp3 files, and the t2 folder, leaving C:\test with no files
and no subdirectories.

Any ideas?

Thanks

-Jeff

 
Reply With Quote
 
 
 
 
Pegasus
Guest
Posts: n/a
 
      14th Jun 2007

"jeffbg123" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to find a batch command that takes a directory and deletes
> all files in that directory, along with subdirectories, leaving an
> empty top level folder.
>
> For instance I have a directory C:\test. In C:\test there are 5 .txt
> files and another directory called C:\test\t2. In C:\test\t2 there are
> 7 mp3 files. I want a command that will delete all of the txt files,
> all of the mp3 files, and the t2 folder, leaving C:\test with no files
> and no subdirectories.
>
> Any ideas?
>
> Thanks
>
> -Jeff
>


Here are a couple of methods:

@echo off
rd /s /q c:\Test
md c:\Test

@echo off
for /d %%a in (c:\Test\*.*) do rd /s /q "%%a"
del /q c:\Test\*.*


 
Reply With Quote
 
jeffbg123
Guest
Posts: n/a
 
      14th Jun 2007
Thanks. Is there any way to do it without having to enter the
directory in more than once?


On Jun 14, 12:45 pm, "Pegasus" <I...@fly.com> wrote:
> "jeffbg123" <jeffbg...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> >I am trying to find a batch command that takes a directory and deletes
> > all files in that directory, along with subdirectories, leaving an
> > empty top level folder.

>
> > For instance I have a directory C:\test. In C:\test there are 5 .txt
> > files and another directory called C:\test\t2. In C:\test\t2 there are
> > 7 mp3 files. I want a command that will delete all of the txt files,
> > all of the mp3 files, and the t2 folder, leaving C:\test with no files
> > and no subdirectories.

>
> > Any ideas?

>
> > Thanks

>
> > -Jeff

>
> Here are a couple of methods:
>
> @echo off
> rd /s /q c:\Test
> md c:\Test
>
> @echo off
> for /d %%a in (c:\Test\*.*) do rd /s /q "%%a"
> del /q c:\Test\*.*





 
Reply With Quote
 
Pegasus
Guest
Posts: n/a
 
      14th Jun 2007
Why would it matter in a batch file?

You can, of couse, set an intial variable, then refer to
to it on all subsequent occasions, e.g. like so:

@echo off
set name=Jeff
echo My name is %name%


"jeffbg123" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks. Is there any way to do it without having to enter the
> directory in more than once?
>
>
> On Jun 14, 12:45 pm, "Pegasus" <I...@fly.com> wrote:
>> "jeffbg123" <jeffbg...@gmail.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>>
>>
>> >I am trying to find a batch command that takes a directory and deletes
>> > all files in that directory, along with subdirectories, leaving an
>> > empty top level folder.

>>
>> > For instance I have a directory C:\test. In C:\test there are 5 .txt
>> > files and another directory called C:\test\t2. In C:\test\t2 there are
>> > 7 mp3 files. I want a command that will delete all of the txt files,
>> > all of the mp3 files, and the t2 folder, leaving C:\test with no files
>> > and no subdirectories.

>>
>> > Any ideas?

>>
>> > Thanks

>>
>> > -Jeff

>>
>> Here are a couple of methods:
>>
>> @echo off
>> rd /s /q c:\Test
>> md c:\Test
>>
>> @echo off
>> for /d %%a in (c:\Test\*.*) do rd /s /q "%%a"
>> del /q c:\Test\*.*

>
>
>
>



 
Reply With Quote
 
jeffbg123
Guest
Posts: n/a
 
      14th Jun 2007
I am trying to make a quick way to clear the cache of dreamweaver. The
most effective way seems to delete the contents of the cache
directories. There are about 10 directories to delete and I have to do
this on about 6 different computers, each having different
directories. So I want to setup a template that I can modify.

Something like this does not seem to work:

@echo off
set direc = "C:\test\"

RD /S /Q %direc%
MD %direc%

What did I do wrong?




On Jun 14, 1:39 pm, "Pegasus" <I...@fly.com> wrote:
> Why would it matter in a batch file?
>
> You can, of couse, set an intial variable, then refer to
> to it on all subsequent occasions, e.g. like so:
>
> @echo off
> set name=Jeff
> echo My name is %name%
>
> "jeffbg123" <jeffbg...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
> > Thanks. Is there any way to do it without having to enter the
> > directory in more than once?

>
> > On Jun 14, 12:45 pm, "Pegasus" <I...@fly.com> wrote:
> >> "jeffbg123" <jeffbg...@gmail.com> wrote in message

>
> >>news:(E-Mail Removed)...

>
> >> >I am trying to find a batch command that takes a directory and deletes
> >> > all files in that directory, along with subdirectories, leaving an
> >> > empty top level folder.

>
> >> > For instance I have a directory C:\test. In C:\test there are 5 .txt
> >> > files and another directory called C:\test\t2. In C:\test\t2 there are
> >> > 7 mp3 files. I want a command that will delete all of the txt files,
> >> > all of the mp3 files, and the t2 folder, leaving C:\test with no files
> >> > and no subdirectories.

>
> >> > Any ideas?

>
> >> > Thanks

>
> >> > -Jeff

>
> >> Here are a couple of methods:

>
> >> @echo off
> >> rd /s /q c:\Test
> >> md c:\Test

>
> >> @echo off
> >> for /d %%a in (c:\Test\*.*) do rd /s /q "%%a"
> >> del /q c:\Test\*.*



 
Reply With Quote
 
=?iso-8859-1?B?tK9gty4uID48KSkpuj5g?=
Guest
Posts: n/a
 
      14th Jun 2007
the information you provided in
this posting is a lot different than
your final one to Pegasus.

my suggestion would be to
acquire a new skill here:

http://www.microsoft.com/technet/scr...r/default.mspx

you may find something
useful in the repository......

- db

"jeffbg123" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to find a batch command that takes a directory and deletes
> all files in that directory, along with subdirectories, leaving an
> empty top level folder.
>
> For instance I have a directory C:\test. In C:\test there are 5 .txt
> files and another directory called C:\test\t2. In C:\test\t2 there are
> 7 mp3 files. I want a command that will delete all of the txt files,
> all of the mp3 files, and the t2 folder, leaving C:\test with no files
> and no subdirectories.
>
> Any ideas?
>
> Thanks
>
> -Jeff
>


 
Reply With Quote
 
Pegasus
Guest
Posts: n/a
 
      14th Jun 2007
I can't tell what's wrong with your batch file unless you post
the error message(s) you see.

In your situation a better method might go like this:

@echo off
echo.
set /p folder=Please enter the folder to be deleted:
if "%folder%"=="" goto :eof
echo Clearing "%folder%" . . .
rd /s /q "%folder%"
md "%folder%"
echo Done! Press the space bar to close this window.
pause > nul


"jeffbg123" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to make a quick way to clear the cache of dreamweaver. The
> most effective way seems to delete the contents of the cache
> directories. There are about 10 directories to delete and I have to do
> this on about 6 different computers, each having different
> directories. So I want to setup a template that I can modify.
>
> Something like this does not seem to work:
>
> @echo off
> set direc = "C:\test\"
>
> RD /S /Q %direc%
> MD %direc%
>
> What did I do wrong?
>
>
>
>
> On Jun 14, 1:39 pm, "Pegasus" <I...@fly.com> wrote:
>> Why would it matter in a batch file?
>>
>> You can, of couse, set an intial variable, then refer to
>> to it on all subsequent occasions, e.g. like so:
>>
>> @echo off
>> set name=Jeff
>> echo My name is %name%
>>
>> "jeffbg123" <jeffbg...@gmail.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>> > Thanks. Is there any way to do it without having to enter the
>> > directory in more than once?

>>
>> > On Jun 14, 12:45 pm, "Pegasus" <I...@fly.com> wrote:
>> >> "jeffbg123" <jeffbg...@gmail.com> wrote in message

>>
>> >>news:(E-Mail Removed)...

>>
>> >> >I am trying to find a batch command that takes a directory and
>> >> >deletes
>> >> > all files in that directory, along with subdirectories, leaving an
>> >> > empty top level folder.

>>
>> >> > For instance I have a directory C:\test. In C:\test there are 5 .txt
>> >> > files and another directory called C:\test\t2. In C:\test\t2 there
>> >> > are
>> >> > 7 mp3 files. I want a command that will delete all of the txt files,
>> >> > all of the mp3 files, and the t2 folder, leaving C:\test with no
>> >> > files
>> >> > and no subdirectories.

>>
>> >> > Any ideas?

>>
>> >> > Thanks

>>
>> >> > -Jeff

>>
>> >> Here are a couple of methods:

>>
>> >> @echo off
>> >> rd /s /q c:\Test
>> >> md c:\Test

>>
>> >> @echo off
>> >> for /d %%a in (c:\Test\*.*) do rd /s /q "%%a"
>> >> del /q c:\Test\*.*

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch delete of accounts PhilAllen Microsoft Outlook BCM 2 4th Dec 2008 11:12 AM
Batch Delete VB code pgarcia Microsoft Excel Programming 12 24th Sep 2008 11:27 PM
batch delete =?Utf-8?B?amFzb24yNDQ0?= Microsoft Excel Misc 1 21st Sep 2006 04:01 AM
Batch delete tables =?Utf-8?B?S2V2aW4=?= Microsoft Access VBA Modules 6 18th Mar 2006 06:06 PM
batch delete Karl Windows XP Help 5 17th Feb 2005 06:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 AM.