recursive find to display directory

  • Thread starter Thread starter William Hymen
  • Start date Start date
W

William Hymen

Quite some time ago I installed the MKS
tookit, which gives me "unix find", grep, egrep, etc.
But, I need to recursively find and display a folder
but not hte contents, from 2 or 3 snippits of the filename-
e.g.

cd d:\file_data\root_folder
unix-find.exe . | grep -i fx | grep -i serve | grep -i 2.3

retrurns eight hits, including the files.

d:\file_data\root_folder\inbox\fxapp_server2.3
d:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.zip
d:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.md5
d:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.txt
::
d:\file_data\root_folder\outbox\fxapp_server2.3
d:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.zip
d:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.md5
d:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.txt

Preferrably, I need a NT script or VB script to return just
the root folders, *not* the contents, when I pass the
two or three search strings: e.g. fx server 2.4

should return just:
d:\file_data\root_folder\inbox\fxapp_server2.3
d:\file_data\root_folder\outbox\fxapp_server2.3


Thanks in advance-

Bill
 
William said:
Quite some time ago I installed the MKS
tookit, which gives me "unix find", grep, egrep, etc.
But, I need to recursively find and display a folder
but not hte contents, from 2 or 3 snippits of the filename-
e.g.

cd d:\file_data\root_folder
unix-find.exe . | grep -i fx | grep -i serve | grep -i 2.3

retrurns eight hits, including the files.

d:\file_data\root_folder\inbox\fxapp_server2.3
d:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.zip
d:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.md5
d:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.txt
::
d:\file_data\root_folder\outbox\fxapp_server2.3
d:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.zip
d:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.md5
d:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.txt

Preferrably, I need a NT script or VB script to return just
the root folders, *not* the contents, when I pass the
two or three search strings: e.g. fx server 2.4

should return just:
d:\file_data\root_folder\inbox\fxapp_server2.3
d:\file_data\root_folder\outbox\fxapp_server2.3
Dir supports multiple asterisks. If you specify in the proper order,
this should do: (provided you don't enter 2.4 and don't expect to
return 2.3 ;-)

cd d:\file_data\root_folder
DIR /AD /S/B *fx*server*2.4*

HTH
 
On Thu, 24 Feb 2005 22:21:31 -0500, "William Hymen"
microsoft.public.win2000.cmdprompt.admin,
microsoft.public.windows.server.scripting (not propagated here, thus
culled]:
How would I force 8.3 filenames?
[snip]

CMD's DIR /X is a start, but parsing its output is a bummer.
DIR /X /Z under 4NT/4DOS is more consistent and easier to parse.
But I doubt short filenames would help as they would lose any
resemblance to the original names.

But then again, with 4NT's/4DOS's extended wild card capabilities
there's no need for parsing or grep:

The test bed:

$ DIR /B /S
E:\file_data
E:\file_data\root_folder
E:\file_data\root_folder\inbox
E:\file_data\root_folder\outbox
E:\file_data\root_folder\inbox\fxapp_server2.3
E:\file_data\root_folder\inbox\fxapp_server2.4
E:\file_data\root_folder\inbox\xfapp_server2.3
E:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.md5
E:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.txt
E:\file_data\root_folder\inbox\fxapp_server2.3\fxapp_server2.3.zip
E:\file_data\root_folder\inbox\fxapp_server2.4\fxapp_server2.4.md5
E:\file_data\root_folder\inbox\fxapp_server2.4\fxapp_server2.4.txt
E:\file_data\root_folder\inbox\fxapp_server2.4\fxapp_server2.4.zip
E:\file_data\root_folder\outbox\fxapp_server2.3
E:\file_data\root_folder\outbox\fxapp_server2.4
E:\file_data\root_folder\outbox\xfapp_server2.3
E:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.md5
E:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.txt
E:\file_data\root_folder\outbox\fxapp_server2.3\fxapp_server2.3.zip
E:\file_data\root_folder\outbox\fxapp_server2.4\fxapp_server2.4.md5
E:\file_data\root_folder\outbox\fxapp_server2.4\fxapp_server2.4.txt
E:\file_data\root_folder\outbox\fxapp_server2.4\fxapp_server2.4.zip

Note there are two directories with "xf" instead of "fx" as control
case.

Now, with 4NT:

$ DIR /A:D /S /B *fx*serv*2.[34]
E:\file_data\root_folder\inbox\fxapp_server2.3
E:\file_data\root_folder\inbox\fxapp_server2.4
E:\file_data\root_folder\outbox\fxapp_server2.3
E:\file_data\root_folder\outbox\fxapp_server2.4

or, if you only want "2.3":

$ DIR /A:D /S /B *fx*serv*2.3
E:\file_data\root_folder\inbox\fxapp_server2.3
E:\file_data\root_folder\outbox\fxapp_server2.3

As Matthias rightly pointed out, CMD can do the latter, too.

If you then want short filenames, under 4NT:

$ DIR /A:D /S /B /X *fx*serv*2.3
E:\FILE_D~1\ROOT_F~1\inbox\FXAPP_~1.3
E:\FILE_D~1\ROOT_F~1\outbox\FXAPP_~1.3

CMD doesn't do that either - it just disregards /X in this combination
of switches. You have to incorporate the DIR command into FOR and its
baroque variable substitutions, probably %~fsI or %~sI:

E:\>FOR /F %I IN ('DIR /A:D /S /B *fx*serv*2.3') DO @ECHO %~sI
E:\FILE_D~1\ROOT_F~1\inbox\FXAPP_~1.3
E:\FILE_D~1\ROOT_F~1\outbox\FXAPP_~1.3

4NT's DIR command is documented at <http://jpsoft.com/help/dir.htm>.
4DOS should work the same. 4DOS is free, 4NT is not.
 
Back
Top