[<<]Message[>>]    [<<]Author[>>]    [<<]Subject        [<<]Thread[>>]

Number : 1715 Date : 2002-03-03 Author : Richard Kirkham Subject : Re: Mixed results with Kan's WHERE.BAT Size(KB) : 6
Can that be directed into a text file? Rick --- Kan Yabumoto wrote: > > rotaiv's asked a question about the WHERE.BAT script > which was > introduced as one of my favorite one-liner batch > script based on > XXCOPY's /L operation. > > My original version of WHERE.BAT appeared in my > article which > appeared Ed Jablonowski's BootList's special edition > (#005) > on early February. Here's what I wrote > > ################################################################## > > 6. A One-Liner Batch File for You. > > Who in their right mind need to go wild with the > Wild-Wildcard? > > You seldom need to go very wild in filespec. > But, the ultimate > flexibility in XXCOPY becomes very handy when you > look for > something in your disk. Since you don't want to > remember > the XXCOPY switches that work best for file > searches, a batch > file really makes your life easier. > > Here is my favorite batch file: > > where.bat > > ----------------------------------------------------- > xxcopy /lzdl/s/h %1 %2 %3 %4 %5 %6 %7 %8 %9 > > ----------------------------------------------------- > > It is a file-finder script. It often works best > with a > pathname that starts with the root (but need not > to). > With this batch file, I sometimes go quite wild. > You may add any "adjective" using the xxcopy > switches > > examples: > > where \windows\*\cache*\ // list all in cache > dirs > where \*\temp*\ /sz:0 // zero-byte files > in temp dirs > where \ /da#10m // made in the past > 10 min > where \mydir\ \ref\ /u // files common in > both dirs > > This simple batch script exemplifies the > flexibility of > XXCOPY by allowing many ways to select files. > For instance, > the fourth example above shows off some nifty > combination. > > ################################################################### > > rotaiv showed me a neat shorthand, "%*" which > replaces my > "%1 %2 ... %9" which I was not aware of (I never > claim to > be a batch-file guru). > > So, the improved WHERE.BAT is as follows: > > where.bat > --------------------------------- > xxcopy /lzdl/s/h %* > --------------------------------- > > In the article, I gave just four examples. For some > reason, > in all of the examples that I listed, the source > specifiers > were always ended with a backslash (\). Probably, I > should > have added a few more examples which show very > common usages > with a filename pattern (to avoid the false > impression that the > command requires a directory name). So, let me add > a few more > examples: > > where \windows\*\cache*\ > where \windwos\*\cache*\*.jpg > > Recall what XXCOPY does with a source specifier > which ends > with a directory name (without a filename pattern). > It is > equivalent to specifying "any" name (*). The second > example > here limits the listing to files that ends with > ".jpg" instead > of "any file". > > Let me add two more examples with different > filtering mechanisms. > > where \*.mp3 /sz:10m- // MP3 files 10MB or > larger > where \*.gif /in*.jpg /in*.bmp // list various > image files > > ---------------------------------------------------------------- > > As far as I know, the WHERE.BAT script works well > and the > simplicity encourages the users to try different > ways to > search for files. > > I guess rotaiv's frustration comes from the obscure > /LTREE > operation. It is not the fault of the WHERE.BAT > scheme. > So, let me address the /LTREE question. > > The /LTREE operation was added back in June of 2001 > in > response to a customer's request. It served the > purpose > but was never really polished to be truly versatile. > Admittedly, its behavior is not well documented. > > /LTREE is to list the "tree structure" that is, the > directory > names that are selected by various qualifiers. When > it is > used with the /DA/DB/DO switches, it even use > directory's > timestamp (rather than the usual timestamp of > files). > > Since /LTREE lists directories, it ignores the > patterns for > the filename which are specified in the command > line. > > So, as rotaiv observed, in order to list "SendTo" > directories, > > where c:\winnt\*\send*\ /ltree // a lazy way to > specify sendto > wehre c:\winnt\*\sendto\ /ltree // a precise way > to list sendto > > In either case, /LTREE will list all subdirectories > under c:\winnt > that match either "send*" or "sendto", respectively. > > Now, let me examine the anatomy of this operation; > When you say > > where c:\winnt\*\send* // "send*" as filename > template. > > The source specifier syntax here is clearly to look > for files > whose name starts with "send". The important thing > here is > that the specifier stipulates that the last element > listed here > is for the filename pattern (it does not have the > terminating > backslash to denote a directory). > > Now, let us add /LTREE which is to list the > directory names > (it ignores the filename pattern). The command > > where c:\winnt\*\send* /ltree > > is equivalent to > > where c:\winnt\*\* /ltree // LTREE > ignores filenames. > > Therefore, it lists all subdirectories under > c:\winnt. You > may call this behavior lousy. But, it seems to be a > no-win > situation for XXCOPY design. (Yes, XXCOPY could > reject the > source specifier with any filename pattern other > than "*" with > the /LTREE as a syntax error.) > > Anyway, that is how /LTREE behaves as of this > writing. > > > Conclusion: > > Going back to rotaiv's comment on WHERE.BAT, I > believe the > WHERE.BAT scheme is quite sound and I have > nothing to change > except to incorporate the neat "%*" argument. We > should > treat the /LTREE case as a separate issue. > Currently, /LTREE > switch is good for a simple operation of listing > directories. > > Kan Yabumoto > ---------------------------------------------------------------- > > At 2002-03-01 12:20, you wrote: > >Kan, > > > >I was practicing with your infamous WHERE.BAT and I > was trying to list all > >the "SendTo" directories in the NT profiles > directory. I eventually > >figured out the following works: > > > > where c:\winnt\*\send*\ /ltree > > > >However, in the course of my experimenting, I tried > this: > > > > where c:\winnt\*\send* /ltree > > > >Not only did it not work, I have no idea why I got > the results I > >did! Obviously, it has to do with the "/" at the > end of the file spec but > >why did I see "ALL" directories? > > > >Here is the contents of the batch file: > > > > @xxcopy /lzdl/s/h %* > > > >Note - I got lazy and used "%*" instead of listing > each of the nine > >parameters ;) > > > >rotaiv. > > > ------------------------ Yahoo! Groups Sponsor > > > > Your use of Yahoo! Groups is subject to > http://docs.yahoo.com/info/terms/ > > __________________________________________________ Do You Yahoo!? Yahoo! Sports - sign up for Fantasy Baseball http://sports.yahoo.com