Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Question on NOT traversing subdirectories with DO

May
62
1
I don't know whether this is intentional DO behavior. The documentation states that the /D option (specify a starting directory) is for use with the /S option (traverse subdirectories). The /D option may be specified without the /S option, without error. However, in this case it is ignored. In other words, there's no way to say "start in this other directory, but do not traverse subdirectories." WAD or not?
Code:
[C:\batch]do file in /d"h:\" image* (echo %file (in %_cwd))
imagehelp.btm (in C:\batch)

[C:\batch]do file in /d"h:\" /s image* (echo %file (in %_cwd))
Image1.jpg (in H:\)
Image10.jpg (in H:\)
image2.jpg (in H:\)
image20.jpg (in H:\)
It's easy enough to guard against with surrounding code, but I thought I'd ask.
 
Hmmm! I thought "/s0" would do it but it doesn't (acts like "/s"). "/s0" works for DIR. Is this a bug?
 
Yes, that does work. But you definitely do not want to use the /s option with that syntax, because it will traverse the current directory, not the named one:
Code:
[C:\batch]do file in /s h:\image* (echo %file^t^t%_cwd)
H:\Image1.jpg           C:\batch
H:\Image10.jpg          C:\batch
H:\image2.jpg           C:\batch
H:\image20.jpg          C:\batch
H:\Image1.jpg           C:\batch\Alan
H:\Image10.jpg          C:\batch\Alan
H:\image2.jpg           C:\batch\Alan
H:\image20.jpg          C:\batch\Alan
H:\Image1.jpg           C:\batch\BAT
H:\Image10.jpg          C:\batch\BAT
H:\image2.jpg           C:\batch\BAT
H:\image20.jpg          C:\batch\BAT
H:\Image1.jpg           C:\batch\CharlesG
H:\Image10.jpg          C:\batch\CharlesG
...
Which, I suppose, agrees with the documentation. But the inconsistency noted in post #1 is still there.
 
@rconn - I believe this is a bug - please see post #4 above....

@old coot - see from #4 that maybe c:\batch\CharlesG might be me - at least it's my first name and last initial - LOL
 
I don't know whether this is intentional DO behavior. The documentation states that the /D option (specify a starting directory) is for use with the /S option (traverse subdirectories). The /D option may be specified without the /S option, without error. However, in this case it is ignored. In other words, there's no way to say "start in this other directory, but do not traverse subdirectories." WAD or not?

WAD, because it wouldn't save any effort vs. just doing a CDD first. DO /D will only work with a matching /S.

I think you're misinterpreting the /D - it does not mean "start the DO processing in this directory", it means "start the recursion in this directory".
 
@rconn

Ahhh, THAT IS THE POINT.

I also misinterpreted it. Maybe it would be useful to make it clearer in the help somehow ... I am very sure that many people misinterpreting this.
 
The help is written in a way that separates /D and /S parameters, and even make the /D switch appear required where all other parameters are optional.
I, too, was hit by this issue just now.
 

Similar threads

Back
Top