A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » Security and Administration with Windows XP
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

batch file help



 
 
Thread Tools Display Modes
  #1  
Old October 14th 05, 11:07 AM
james
external usenet poster
 
Posts: n/a
Default batch file help

Hi there,
I am trying to write a batch file that takes as an arquemant a directory to
look for, searches the current directory and all sub directories for a
directory of that name and deletes each one it finds.
The command that I am using is
FOR /F %%i IN ('dir /b /s /ad %1*') DO rd %%i
and the problem is that if I have a directory structure say dir\dir the
script deletes the sub directoryvand not the top level dir.

Could someone please advise why this is so and how I can modify this
behaviour.

Am I using the right command to display all directories below the current of
a given name. I have noted that the command "dir /b /ad dir_Name" displays
the
contents of directoty named dir_Name but wont list directories in the
current directory named dir_Name.

Regards,
James.

Ads
  #2  
Old October 16th 05, 04:12 PM
cquirke (MVP Windows shell/user)
external usenet poster
 
Posts: n/a
Default batch file help

On Fri, 14 Oct 2005 03:07:01 -0700, "james"

I am trying to write a batch file that takes as an arquemant a directory to
look for, searches the current directory and all sub directories for a
directory of that name and deletes each one it finds.
The command that I am using is


FOR /F %%i IN ('dir /b /s /ad %1*') DO rd %%i


and the problem is that if I have a directory structure say dir\dir the
script deletes the sub directoryvand not the top level dir.


You may be up against the bottom-up way /F processes subtrees.

One way might be to expand the For statement to Set a variable when a
match is found, and then loop to re-run the entire For statement until
this variable is no longer Set. Messy if applied to laaarge subtrees.



--------------- ---- --- -- - - - -

I'm baaaack!
--------------- ---- --- -- - - - -

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows update for KB896358 doesnot install Shafeeq-LSHTM General XP issues or comments 4 July 27th 05 06:37 PM
explorer only works if I rename it Dave Sell General XP issues or comments 7 June 3rd 05 01:33 PM
Can't install Critical Update for Windows XP Media Center Edition2004 (KB838358) Ant General XP issues or comments 7 May 19th 05 03:21 AM
Can't install Critical Update for Windows XP Media Center Edition2004 (KB838358) Ant Windows XP Help and Support 7 May 19th 05 03:21 AM
Help please with VX2, IGETNET, ugroup and popups Mctabish Windows XP Help and Support 3 December 16th 04 12:35 AM






All times are GMT +1. The time now is 09:48 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.